...

View Full Version : Renaming upload files



Daum
06-13-2005, 08: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.

Daum

Coastal Web
06-13-2005, 11:15 PM
I dont understand, why wouldn't something like:


<?php
//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
<br>
It has a $ext extension
<br>
I will rename your file:
$newname
end;
?>


Do the trick?

Samantha Gram



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum