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
renaming a file while uploading it
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
I usually just md5() for a unique filename in combination with file_exists(), and simply use that value when using move_uploaded_file()
Last edited by John Cartwright on Wed Dec 06, 2006 9:02 am, edited 1 time in total.
- Skittlewidth
- Forum Contributor
- Posts: 389
- Joined: Wed Nov 06, 2002 9:18 am
- Location: Kent, UK
Use
and add or prefix a timestamp to the $destination filename?
Doh, you beat me to it Jcart!
Code: Select all
move_uploaded_file($tmpname, $destination)Doh, you beat me to it Jcart!