class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
1. There is a bug in the upload.php demo/test program. It will fail if you try to upload a huge file - like over 8MB. The $_FILE variable is empty, and causes several runtime errors - the first in the call to instantiate the object.
2. So what is with the file size limit thing anyway? My phpinfo() result says there is a 2MB limit, and indeed, a 3MB file will produce the right error. If I try any file between 2MB and 8MB, things work as one would expect (thank god for local development servers to check big files quickly!), but on my configuration (pretty standard Ubuntu server), once the file goes above 8MB, I get an entirely different error. First, the $FILE is empty, and second, there's a runtime warning that the 8MB limit has been exceeded. I don't know where that limit gets set, and why it is different than the 2MB limit reproted by phpinfo().
3. Given that, is there a good JavaScript solution that can check the true filesize limit client side so the user doesn't upload a 2+MB file, and then get the error message?Reply
This is certainly very useful information for those of us new to uploading. Thanks for the reply.
And I've also learned that the file size checking can happen both server and client side. The class upload demo only checks AFTER the file has been uploaded, thus leaving things open to crashing on really big files upon running out of PHP memory. I've learned you can also do some simple non-JS client side checking by putting a hidden input html before the "file" input html: <input name="MAX_FILE_SIZE" value="150000" type="hidden" /> This will stop the upload client-side, and I would think was an essential part of any upload form.
It is so hard to find all these little details by simply reading documentation.Reply
2. So what is with the file size limit thing anyway? My phpinfo() result says there is a 2MB limit, and indeed, a 3MB file will produce the right error. If I try any file between 2MB and 8MB, things work as one would expect (thank god for local development servers to check big files quickly!), but on my configuration (pretty standard Ubuntu server), once the file goes above 8MB, I get an entirely different error. First, the $FILE is empty, and second, there's a runtime warning that the 8MB limit has been exceeded. I don't know where that limit gets set, and why it is different than the 2MB limit reproted by phpinfo().
3. Given that, is there a good JavaScript solution that can check the true filesize limit client side so the user doesn't upload a 2+MB file, and then get the error message?
And I've also learned that the file size checking can happen both server and client side. The class upload demo only checks AFTER the file has been uploaded, thus leaving things open to crashing on really big files upon running out of PHP memory. I've learned you can also do some simple non-JS client side checking by putting a hidden input html before the "file" input html:
<input name="MAX_FILE_SIZE" value="150000" type="hidden" />
This will stop the upload client-side, and I would think was an essential part of any upload form.
It is so hard to find all these little details by simply reading documentation.