To rename the file, you can use Move_Uploaded_File. The best way to do this is to make a table in your database to store the photo info in. Include a column in this table that is an auto incrementing unique id. When the photo gets uploaded, first thing, add a row into the database with info about the photo, such as width, height, whatever. Use Mysql_Insert_ID to return the unique id of that column. Then just move the uploaded file (rename) it to "returned unique id.jpg"