note 38368 deleted from function.rename by irchtml
| From: | irchtml@php.net | Date: | Sun, 29 Feb 2004 16:15:00 +0000 |
| Subject: | note 38368 deleted from function.rename by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65995@lists.php.net to get a copy of this message | ||
Note Submitter: thespinicrus@hotmail.com
----
this code will help you rename a file, without taking care of it's extension. for example if
you have a comunity website, and the user uploads it's picture, you'll probably want the
name of the image to be unique... like the user, or maybe the image will take the name of the
user...:
$rename = 'new_name'; //or $rename = $username;
$file_name = $_FILES['userfile']['name'];
$read_extension = explode(".", $file_name);
$ext = $read_extension[1];
$renamed = $rename.".".$ext;
rename($file_name, $renamed);