PDA

View Full Version : Rename an uploaded file


Keiichi
03-31-2001, 05:39 PM
i have a topsite script and each member has a unique id based on time().

i want to put an upload script that uploads image (.jpg, .jpeg, and .gif) in it.
How would you go about renaming the file to the member id and keeping the same extention that it already is? (so others couldn't overwrite others files in the same directory)

so for ex. an image uploaded was name "bob.gif" would be converted to 935252323.gif, or a john.jpg uploaded would be 935252323.jpg

(oh, and it would be great if this "935252323.gif" value be stored in a variable so i can add the name to mysql)

thanks for any replies.
------------------
K1

jbroder
04-06-2001, 02:58 PM
I have done this with a perl upload script and then just put a command at the end
`mv $filename $timestamp.gif`

For php upload instructions, there is a tutorial on this site. I believe it includes renaming instructions.

Hope this helps.

Keiichi
04-07-2001, 04:25 AM
oh, i had already got it. i used eregi() to look for the extension and renamed it to the time. :)