harkly Posted April 8, 2010 Share Posted April 8, 2010 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!"; } } Quote Link to comment https://forums.phpfreaks.com/topic/198032-uploading-images/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 8, 2010 Share Posted April 8, 2010 You should use an array and a loop. See example #3 at this link - http://us.php.net/manual/en/features.file-upload.post-method.php Quote Link to comment https://forums.phpfreaks.com/topic/198032-uploading-images/#findComment-1039117 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.