Page 1 of 1

renaming a file while uploading it

Posted: Wed Dec 06, 2006 8:54 am
by hame22
I would like to rename a file as I upload it to the server, so as to give it a unique name, how can this be achieved?

Thanks in advance

Posted: Wed Dec 06, 2006 8:57 am
by John Cartwright
I usually just md5() for a unique filename in combination with file_exists(), and simply use that value when using move_uploaded_file()

Posted: Wed Dec 06, 2006 9:01 am
by Skittlewidth
Use

Code: Select all

move_uploaded_file($tmpname, $destination)
and add or prefix a timestamp to the $destination filename?

Doh, you beat me to it Jcart!