Join 136,492 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,710 people online right now. Registration is fast and FREE... Join Now!
This is being called from a file upload form. Regardless of the tweaks and strings I pull on this, I keep getting an invalid file message. I know I missed something probably simple, but being relatively new to php, I can't seem to spot it. Thanks in advance
The error message that you are getting is the else to this if. So this is the statement that is failing & forcing you into the else code block, reporting the error.
1.) Try to use the file name extension 2.) In your error, output the value of $_FILES["file"]["type"] to get a better idea of what's going on with the code.
php
echo "File type ".$_FILES['file']['type']." is not supported";
1.) Try to use the file name extension 2.) In your error, output the value of $_FILES["file"]["type"] to get a better idea of what's going on with the code.
php
echo "File type ".$_FILES['file']['type']." is not supported";
//be aware that if this is above server http root, someone can delete them. //is beter to store below it and use another page to get them, that has cleaning for the dir name and file name. $upload_dir = 'upload/';
if(!is_writable($upload_dir)) exit($upload_dir.' Dir is not writable.');
if($_FILES["file"]["size"] > 0) if ($_FILES["file"]["size"] < 10000000){ if(!in_array($_FILES["file"]["type"],$types)){ echo '"'.$_FILES["file"]["type"].'" File type not allowd.';
} else if (is_file($upload_dir . $_FILES["file"]["name"])){
echo '"'.$_FILES["file"]["name"].'" already exists. rename and try again.';
Thanks, I did change the upload dir. and I did manage to debug most of this code, however i'm having a problem with the upload dir being un-writable. I've set it to write and still no change.