Hello,
I am trying to upload 1 or more images from a form too the server...and add the file name to a mysql database.
I am able to get it to work for 1 file at a time....but what if I want to add more than 1? My code is below:
if($_FILES['mainphoto']['name'] == '') {
echo 'You did not select a photo to upload';
}
elseif($_FILES['mainphoto']['size'] == 0) {
echo 'There appears to be a problem with the photo your are uploading';
}
elseif($_FILES['mainphoto']['size'] > $MAX_FILE_SIZE) {
echo 'The photo you selected is too large';
}
elseif(!getimagesize($_FILES['mainphoto']['tmp_name'])) {
echo 'The photo you selected is not a valid image file';
}
else {
$uploaddir = '/httpd/customers/virtual/mydomain.com/htdocs/search/rental_photos/'; // remember the trailing slash!
$uploadfile = $uploaddir. $_FILES['mainphoto']['name'];
if(move_uploaded_file($_FILES['mainphoto']['tmp_name'], $uploadfile))
{
print "<body>
<div align='center'>Your listing has been added<br>
<img src='$photo_name'></div>
</body>
</html>";
}
else {
echo 'There was a problem uploading your file.<br>';
}
}
It works just fine..... mainphoto is the form variable.....but how should I handle the other images from the form photo2,photo3,photo4?
Oh.... I should mention that this
$photo_name = $_FILES[mainphoto][name];
Is on the top of the script, so I can get the file name properly.....otherwise I get the output of Array