Jump to content


Renaming Uploaded Images

  • Please log in to reply
1 reply to this topic

#1 DBookatay

  • Members
  • PipPipPip
  • Advanced Member
  • 334 posts
  • LocationCT

Posted 27 April 2006 - 04:40 AM

I am working on a internal posting area for my company, where users are asked to upload an image onto the server, and then have the image displayed. I found this code and got it to work properly:

if (is_uploaded_file ($_FILES['image']['tmp_name'])) {
   if (move_uploaded_file($_FILES['image']['tmp_name'], "user_logos/{$_FILES['image']['name']}")) 
        $i = $_FILES['image']['name'];
   } else {
        $i = "";

What I now need to do is be able to rename the images, incase 2 users upload the same image name. Is there an easy way to do this?

$result mysql_query("SELECT finger FROM hand WHERE id=3"); 

#2 sanfly

  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 27 April 2006 - 04:46 AM

Check out the "User Contributed Notes" for [a href=\"http://nz.php.net/manual/en/function.move-uploaded-file.php\" target=\"_blank\"]move_uploaded_file() in the manual[/a], there is a script someone has posted that may be what you are looking for
If you're not part of the solution, you're part of the precipitate

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users