|
|
@@ -769,22 +769,23 @@ class Route_ViewTableAjax extends RouteBase {
|
|
|
if (!$uploader->tryCreateDestFolder($destPath)) throw new Exception("Wystąpił błąd podczas tworzenie katalogu dla rekordu '{$primaryKey}'");
|
|
|
}
|
|
|
|
|
|
- $generateSafeFileName = function($path) {
|
|
|
- if (!file_exists($path)) return $path;
|
|
|
- $infoPath = pathinfo($path);
|
|
|
+ $generateSafeFileName = function($destPath, $fileName) {
|
|
|
+ if (!file_exists("{$destPath}/{$fileName}")) return $fileName;
|
|
|
+ $infoPath = pathinfo($fileName);
|
|
|
// pathinfo('/path/t1/t2/fileName.ext') = [
|
|
|
// [dirname] => /path/t1/t2
|
|
|
// [basename] => fileName.ext
|
|
|
// [extension] => ext
|
|
|
// [filename] => fileName
|
|
|
// ]
|
|
|
- return $infoPath['dirname'] . "/" . $infoPath['filename'] . "--" . date("Y-m-d_H-i-s") . "." . $infoPath['extension'];
|
|
|
+ return $infoPath['filename'] . "--" . date("Y-m-d_H-i-s") . "." . $infoPath['extension'];
|
|
|
};
|
|
|
$moveActions = array_map(function ($file) use ($destPath, $generateSafeFileName) {
|
|
|
+ $safeName = $generateSafeFileName($destPath, $file['name']);
|
|
|
return [
|
|
|
$file['tmp_name'],
|
|
|
- $generateSafeFileName("{$destPath}/{$file['name']}"),
|
|
|
- $file['name'],
|
|
|
+ "{$destPath}/{$safeName}",
|
|
|
+ $safeName,
|
|
|
];
|
|
|
}, $_FILES);
|
|
|
DBG::log($moveActions, 'array', "\$moveActions"); // [ [ srcPath, descPath ] ]
|