September 8th, 2011, 11:21 AM
Uploading Large Files
I need to upload large files through a form.
I've increased the post size limit to 200mb, but since you can't check before it attempts to upload if it is above that - it will attempt to upload before it runs out of memory.
Also uploading a file that is <200mb takes a little while, but I see no option of providing feedback to the client about time remaining.
I've been googling solutions for days, tried out a few - but nothing I can work with.
Is there anything which does this well? Is there anyway I can avoid writing to files to memory before the filesystem as ColdFusion does?
September 8th, 2011, 04:57 PM
You can check CGI.CONTENT_LENGTH on the server before starting the upload with CFFILE. Not perfect but should give you a good idea of the size of what they are trying to upload.
CF 9 added some additional features to handle file uploads, and I believe it now writes the file directly to disk rather than storing it in memory first.
However, uploading large files is really not something you want a web application to handle (whether it is PHP, CF, Java, etc.). The entire time the file is uploading, it is using a processor thread. So depending on how many people are doing this and how big the files are, you can easily use up your entire thread pool.
There are much more efficient ways to do this, such as: http://commons.apache.org/fileupload/
Hope that helps,
September 9th, 2011, 05:26 AM
Originally Posted by kiteless
The problem with CF7 is that the moment you hit 'submit' the entire file is written to memory (ie. uploaded) before you even use CFFile. CFFile is the 'quick bit' copying it from server memory to a file location. It's not until the file has been uploaded to memory that you can use CGI.CONTENT_LENGTH - and if the file was above the post limit of the CF Server - then you won't even get that far! (outofmemory)
I would love my client to upgrade to CF9 Enterprise - but it's not a quick process
Thankfully not many people are likely to be doing this simultaneously - I suspect only 1 person at a time will ever be uploading.
I'll have a look at the fileupload - but unless I find some simpler integration details it might fall outside of my timeframe