How do i stop overwriting of uploaded files?
Moderator: General Moderators
-
mikegotnaild
- Forum Contributor
- Posts: 173
- Joined: Sat Feb 14, 2004 5:59 pm
How do i stop overwriting of uploaded files?
If my users upload a file with the same name as one that is already in the folder what type of coding do i have to do to stop this... I WANT to keep the file names in-tact though. Maybe i could have a folder automatically created for them and then put the files into that folder...?
Re: How do i stop overwriting of uploaded files?
You could do something like:mikegotnaild wrote:If my users upload a file with the same name as one that is already in the folder what type of coding do i have to do to stop this... I WANT to keep the file names in-tact though. Maybe i could have a folder automatically created for them and then put the files into that folder...?
APP_NAME-HHMM-FILENAME.EXT
So if your application was "webthing", then it could prepend the filename to include webthing, and the time it was saved. That way, very very few collisions.
-
mikegotnaild
- Forum Contributor
- Posts: 173
- Joined: Sat Feb 14, 2004 5:59 pm
Roja is refering to the date function, e.g.:
Alternatively, you could check whether the file exists already with
[php_man]file_exists[/php_man]. If true, then prompt user.
Code: Select all
$filename="myFile_".date("His");[php_man]file_exists[/php_man]. If true, then prompt user.
-
mikegotnaild
- Forum Contributor
- Posts: 173
- Joined: Sat Feb 14, 2004 5:59 pm