View Full Version : Renaming upload files

06-13-2005, 09:35 AM
can anyone help me with my renaming method..here is the current code i use to upload files http://pastebin.ca/14234, and i'm attempting to make it so each file is renamed to a number and then attached with the appropiate extension so far i have this..but it doesn't work at all..here is what i got so far...http://pastebin.ca/14235
Thanks in advance for the help.


Coastal Web
06-14-2005, 12:15 AM
I dont understand, why wouldn't something like:

//some variables...

$userfile = "user_uploaded_file.html";
$ext = substr($userfile, strrpos($userfile,"."));
$time = time();
$newname = $time.$ext;

And of course you'd copy the uploaded file and put it where you wanted it...

copy($file_temp, "$newname") or die('could not upload file');

echo <<<end
Your file is named: $userfile
It has a $ext extension
I will rename your file:

Do the trick?

Samantha Gram