1. Home
  2. Computing & Technology
  3. PHP / MySQL

Renaming PHP Uploads

By Angela Bradley, About.com

4 of 4

Saving the file with the new name

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file has been uploaded as ".$ran2.$ext;
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
?>
Finally this code saves the file (with its new name) onto the server. It also tells the user what it is saved as. If there is a problem doing this, an error is returned to the user. Other features such as limiting files by size or restricting certain file types and also be added to this script if you choose.

4 of 4

Index: Renaming PHP Uploads

  1. Uploading the file
  2. Finding the Extention
  3. A Random File Name
  4. Saving the file with the new name

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Advanced PHP
  5. Rename File Upload PHP - Rename PHP Upload - Change Upload Name PHP

©2008 About.com, a part of The New York Times Company.

All rights reserved.