Jump to content

Uploading images


harkly

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.