1. Computing & Technology

Discuss in my forum

Renaming PHP Uploads

By , About.com Guide

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.

©2012 About.com. All rights reserved.

A part of The New York Times Company.