Skip to content

Commit

Permalink
Fix upload of existing files (prasathmani#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ober authored and ner00 committed May 6, 2023
1 parent 0a8623a commit ea9f242
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tinyfilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,6 @@ function get_file_path () {
echo json_encode($response); exit();
}

$override_file_name = false;
$chunkIndex = $_POST['dzchunkindex'];
$chunkTotal = $_POST['dztotalchunkcount'];
$fullPathInput = fm_clean_path($_REQUEST['fullpath']);
Expand Down Expand Up @@ -950,11 +949,6 @@ function get_file_path () {
$fullPath = $path . '/' . basename($fullPathInput);
$folder = substr($fullPath, 0, strrpos($fullPath, "/"));

if(file_exists ($fullPath) && !$override_file_name && !$chunks) {
$ext_1 = $ext ? '.'.$ext : '';
$fullPath = $path . '/' . basename($fullPathInput, $ext_1) .'_'. date('ymdHis'). $ext_1;
}

if (!is_dir($folder)) {
$old = umask(0);
mkdir($folder, 0777, true);
Expand Down Expand Up @@ -1000,7 +994,13 @@ function get_file_path () {
}

if ($chunkIndex == $chunkTotal - 1) {
rename("{$fullPath}.part", $fullPath);
if (file_exists ($fullPath)) {
$ext_1 = $ext ? '.'.$ext : '';
$fullPathTarget = $path . '/' . basename($fullPathInput, $ext_1) .'_'. date('ymdHis'). $ext_1;
} else {
$fullPathTarget = $fullPath;
}
rename("{$fullPath}.part", $fullPathTarget);
}

} else if (move_uploaded_file($tmp_name, $fullPath)) {
Expand Down

0 comments on commit ea9f242

Please sign in to comment.