prasathmani / tinyfilemanager

Single-file PHP file manager, browser and manage your files efficiently and easily with tinyfilemanager
https://tinyfilemanager.github.io
GNU General Public License v3.0
4.61k stars 1.63k forks source link

Overwrite during upload #1133

Closed markknol closed 5 months ago

markknol commented 5 months ago

First of all; what a great project. I was looking for exactly this, just a one pager doing everything you want on a server. I am hoping to use this instead of ftp for a few usages.

Question; is it possible to overwrite a file? Now if I upload a file called index.php it converts that to index_240107200913.php. Maybe I'm missing something but couldnt find an option for this. Would maybe be nice if it was the opposite; the old file get renamed to its datetime, and new file will be called like how you uploaded it. Then you have some kind of version control.

prasathmani commented 5 months ago

@markknol remove the if condition to avoid file name convert https://github.com/prasathmani/tinyfilemanager/blob/8e87afae5b744c3e23490000bf0d398d6d4a749c/tinyfilemanager.php#L1016C17-L1016C17

if ($chunkIndex == $chunkTotal - 1) {
                    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);
                }

you can also check out the recent changes in file name conversation logic PR. https://github.com/prasathmani/tinyfilemanager/commit/00541fc469fe2ddf3fc519c4074490c54380d983