I recently started hosting my own website on my computer, instead of a third party hosting site. I set up the databases, included PHP and everything was running fine under IIS 7 on Vista. However, I have a file upload script that no longer works on my site. the code stayed the same from the other hosting service and on my computer. So I am basically asking whether there a setting or something that needs to be changed in order to allow file upload. In my fileupload.php code, it returns "Invalid File" when the criteria for the image is not met, and every time I try to upload a file in the criteria, I receive that error.
I'm not getting any errors surprisingly. It's just skipping down to the "else statement" as if the image does not fit the criteria.
Also, I have shared the uploads folder with "IIS_IUSRS" making it a co-owner. I am a little unfamiliar with Vista but to my knowledge making IIS a co owner give it all privileges to the directory.
The php.ini file I have allows file uploads with a max limit of 2MB, which I am well under, It just seems weird that the same code works with my other host, but not when I myself host my site.
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
I keep seeing that same crappy upload code. Where are people copying that from?
It does not check the ['error'] element until after it checks the ['type'] and ['size']. People, if there is an error, the type and size will be empty and testing them will fail. You must check for errors before you ever touch any of the data.
Also, by combining all the type and size testing into one conditional statement and one error message, you will never know which test failed.
The error message, which is just echo "Invalid file"; now, needs to output a meaningful message as to what exactly was wrong and what the value was, for example echo $_FILES["file"]["type"]; as part of the error so that you know what was actually received.
It is likely that file uploading is disabled on your server or the temp location for uploading files to does not exist or does not have the proper permissions. You need to check all the runtime values related to uploads using a phpinfo() statement.
I won't even suggest turning on full php error reporting and then checking your web server log file because you probably did those troubleshooting steps before posting your problem in a forum.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
The posted code does not produce that error. In fact, the posted code does not produce any fatal php parse errors.
You would need to post the actual code that caused that error to get help with what is causing it.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.