Handling large file uploads in PHP
I’ve been a bit lax with techy posts recently, so I thought I’d jot down some things I’ve been working on of late.
Playing with Flash Media Server and video encoding, but nothing conclusive to write about yet so watch this space.
What I have had some success with though is handling large file uploads in PHP. It’s something I’ve come across in the past that you soon hit upload_max_filesize or max_execution_time when making web apps to allow upload of files into the megabytes and the slippery slope that is increasing either or both php.ini setting in response to client requests and against better judgement.
In the past I used to set up ftp accounts and say ‘use a proper protocol to transfer files - duh!’ but that’s not exactly user friendly.
So last weekend I went on a hunt for a better solution, and particularly any client-side file upload tools - came across a few that were contenders, and finally settled on JUpload as an interim solution, saving having to code something from scratch.
I’ve previously blogged about my love/hate relationship with Open Source software - here’s one that goes down in my book as a goodie.
It took a bit of fiddling to get the demo code working - it helps if you check out the SVN head - the release package wasn’tquite working. It also took a bit of hunting to find the JUpload PHP class in the wiki which saved me a lot of time writing my own (and reinventing the wheel). It wasn’t handed on a plate how to get it working, but it also wasn’t too hard to figure out.
So I’ve got it breaking everything down into 1MB chunks, and uploads are a whole lot more reliable than just using one big fat HTTP file upload. Whether the applet will survive as is or be modified, or if I will develop something bespoke based perhaps on its core concepts only time will tell, but for now I’ve got bigger fish to tickle.








