Uploading Large Files In PHP

Quite the coincidence... I happen to be working on a form for uploading large files, and an article on Sitepoint pops up in my RSS feeds describing some of the settings to use. Besides the point that a lot of those settings mentioned in the article can not be set using ini_set (check php.net for which directives can be used with ini_set), there is also an issue I just ran into. If you set both your upload_max_filesize and post_max_size the same number, you may be in for a surprise when someone tries to upload too large of a file. What's the surprise? Your form variables will not be available in the php script processing the upload, or at least that is what's happening to me. Since the post_max_size has been exceeded, $_POST is empty. This is a problem if you need variables from the form/$_POST to do a redirect or take some other action. Setting your post_max_size above the upload_max_filesize doesn't seem to help either. It looks like you need to stick the variables you absolutely need in the url and use $_GET to ensure you reliably have them.

Posted In: Uncategorized, PHP

Commentary