Hi all, I have the dir at 777 but I'm just getting "Invalid file", any suggestions why? I had this script working before... <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/permanent_name.jpg"); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> PHP: Thank you
if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) this is your condition.. which is not fullfilled by the file type or file you have uploaded. there might be few things : 1. either the file you have uploaded is more that the size you have mentioned? 2. or the file type you have mentioned is not mentioned? you are only allowed to upload pjpeg,jpeg or gif. you cannot upload other files. your code has no problem.. code is all fine.
can you tell me which file you are uploading and you got the error... please attached that file here...
image file type is highly ureliable use $info = getimagesize($_FILES["file"]["tmp_name"]); $allowed_types = array(IMG_GIF, IMG_JPEG, IMG_PNG); if (in_array($info[2], $allowed_types)) { .... statments ... }
Thank you for your replies. Here is the file: the code is in my first post. Still not working - please help. http://standoutmodels.com/upload.php