Page 1 of 1
Uploading files and renaming on the fly
Posted: Sat Feb 08, 2003 6:54 pm
by sinewave
Dont worry, i understand how to upload files, but how can i rename them to something unique, and what is a good scheme for renaming pictures so there wont be duplicate names and can be added to a db. They will be added one at a time, so the names must come from somewhere. I'm not too sure
any advice?
Posted: Sat Feb 08, 2003 7:33 pm
by patrikG
I've done it with a datetime-stamp (yy)(mm)(dd)(hh)(mm)(ss). I didn't want a random-number - there should still be some kind of order to the images you upload (to my mind :p ).
Code: Select all
$documentfile=ereg_replace(" ","",$documenttitle).(string)date("YmdHis").".".$documentwildcard;
Example: "myImg.gif" will be "myImg200302072013222.gif
Basically every image will get an individual name every second(!). Make sure that on your form you catch double-clicking, i.e. double-submitting.