Jump to content

Recommended Posts

Just need a little point in the right direction.

 

I am allowing the user to upload 5 images. I am wondering if every time they upload should the process for all 5 images run?  I have this but it really doesn't work the way I want it to - should only echo out the error when there is a problem with the image and then show nothing if no image was selected. It uploads and renames the image fine.

 

if ($photo_3 != 'null')
  {
  $extension = strrchr($_FILES['photo_3']['name'],'.');  
  $extension = strtolower($extension); 

  $photoNumber="_3";

  $finalName="$userID$photoNumber";

  $save_path = "uploads/";

  $target_path = $save_path . basename( $_FILES['photo_3']['name']); 

  $NewPhotoName = $finalName; 

  $withExt3 = $NewPhotoName . $extension;

  $filename = $save_path . $NewPhotoName . $extension; 

  if(move_uploaded_file($_FILES['photo_3']['tmp_name'], $filename)) {
$query = "UPDATE photos SET photo_3='$withExt3' WHERE userID='$userID'";

$result = mysql_query($query) or die(mysql_error());
  } else{
    echo "There was an error uploading photo #3, please try again!";
  }

}

 

Link to comment
https://forums.phpfreaks.com/topic/198032-uploading-images/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.