usachrisk — 2008-03-02T11:45:31-05:00 — #1
I have a file upload form that has a target of an IFRAME. The IFRAME does the upload and then updates the parent window with the new file name. If there are file or database errors along the way, those get reported to the parent windows status div as well.
My problem is that if the file is too large, the web server returns error 414 (IIS7) and when this is ready for production and the iframe is hidden, there will be nothing to update my status box.
I've googled around for a solution to have the IFRAME send it's status code to the main window (unlikely) or to have the parent window be able to detect the HTTP status code of the IFRAME (hopefully more likely), but everyone seems to respond to the original poster that you cannot get details about the IFRAME outside of your domain --- but I'm inside of my domain, so I'm hoping for the best!
raffles — 2008-03-02T12:43:41-05:00 — #2
I don't know about this to be honest.
However, are you using MAX_FILE_SIZE in your form? That ought to stop the vast majority of your users from uploading stuff that's too big for your application. If they mess with it, that's their own problem.
usachrisk — 2008-03-02T13:40:47-05:00 — #3
Hi Raffles, I tried adding the following to my form:
<input type="hidden" name="max_file_size" value="100">
But it still allowed me to try and upload a 30mb+ file. I googled around and it looks like this may be a PHP only solution (I only saw it referenced on PHP help pages) - is that correct or am I using it the wrong way?
raffles — 2008-03-02T13:56:00-05:00 — #4
MAX_FILE_SIZE is case sensitive. And it has to appear immediately before the file input field. Also note that the value is in bytes, so 100b is very small.
It isn't PHP-only, it just so happens that PHP is very popular.
Also, if your server is returning errors, perhaps you should address that as well (use of MAX_FILE_SIZE is a good idea anyway so that users can know files are too big before they wait ages for the file to upload only to find out your server-side script won't allow it).
usachrisk — 2008-03-02T17:42:55-05:00 — #5
Thanks Raffles, I'm not using PHP so the php.ini suggestion wont work, but I modified the form to use the hidden input tag in all caps and it's still not working. Here is my form:
<form name="frmRequestForm" method="post" action="request_attachment.cfm" enctype="multipart/form-data" target="testFrame" onsubmit="return check_TF_frmRequestForm(this);">
<input type="HIDDEN" name="requestid" id="requestid" value="94"/>
<input type="hidden" name="MAX_FILE_SIZE" value="100"><input type="FILE" name="attachment" id="attachment"/><br>
<textarea name="description" maxlength="0" id="description" style="width: 100%; height: 60px;"></textarea>
<input type="SUBMIT" name="btnUpload" id="btnUpload" value="Upload"/>
I'm testing with IE7 and FireFox 22.214.171.124
I think 100b is good for testing, it'll be configurable come production time.
usachrisk — 2008-03-02T18:16:12-05:00 — #6
Looks like this is a dead end, I've found it in the PHP manual and also many threads that insist it's PHP only (and that even for PHP it's doesn't work that well). Here is the info from the PHP manual:
Also, there is a PHP bug report that notes that while the PHP Manual says that MAX_FILE_SIZE is a client side workaround for restricting a browser from uploading a file over a certain length, it is not and instead just stops PHP from putting the upload into the FILES array. This bug is documented here:
Oh well, I was excited for a bit Have any thoughts on my original question or perhaps any other workarounds?