Our image upload form always returns the error message, "Invalid file. Please click the 'Back' button on your browser and try again." Here are the basics.


<form enctype=="multipart/form-data" action="phpscript.php" method="post">
<input type="file" name="uploadedfile[]">
<input type="file" name="uploadedfile[]">
<input type="file" name="uploadedfile[]">
<input type="submit" value="Submit" />


if ((($_FILES["uploadedfile"]["type"] == "image/gif")
|| ($_FILES["uploadedfile"]["type"] == "image/jpeg")
|| ($_FILES["uploadedfile"]["type"] == "image/jpg")
|| ($_FILES["uploadedfile"]["type"] == "image/png")
|| ($_FILES["uploadedfile"]["type"] == "image/bmp")
|| ($_FILES["uploadedfile"]["type"] == "image/pjpeg"))
&& ($_FILES["uploadedfile"]["size"] < 20000))
      "http://mydomain.com/uploads/" . $_FILES["uploadedfile"]["name"]);
      $send = mail($to, $subject, $body, $headers);
      header( "Location: http://www.mydomain.com/" );
      else {echo "Invalid file. Please click the 'Back' button on your browser and try again.";}

I've tried rearranging the upload form PHP, but if the form works at all it just sends us the rest of the form information in an email (which we want it to do) but the images never upload to the "uploads" folder. What's wrong?

Notice the "==" besides the enctype attribute.

I would also remove the brackets "[]" from the name.

keith, thanks for the good eye regarding the "=="! I also changed the destination from "http://mydomain.com/uploads/" to basically "home/user/public_html/uploads/" and added bracketed numbers to the end of $_FILES. For example, $_FILES["uploadedfile"]["tmp_name"][0] and $_FILES["uploadedfile"]["tmp_name"][1].


I didn't even look at the php. Nice catch.