Getting HTTP Status Code of IFRAME

Hi Everyone,

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!

Thoughts?

Chris.

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.

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?

Thanks!
Chris.

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. :slight_smile:

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).

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"/>
          File:<br>
          <input type="hidden" name="MAX_FILE_SIZE" value="100"><input type="FILE" name="attachment" id="attachment"/><br>
          <br>
          Description:
          <br>
          <textarea name="description" maxlength="0" id="description" style="width: 100&#37;; height: 60px;"></textarea>

          <input type="SUBMIT" name="btnUpload" id="btnUpload" value="Upload"/>
</form>

I’m testing with IE7 and FireFox 2.0.0.12

I think 100b is good for testing, it’ll be configurable come production time.

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:

http://us.php.net/features.file-upload

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:

http://bugs.php.net/bug.php?id=40387

Oh well, I was excited for a bit :slight_smile: Have any thoughts on my original question or perhaps any other workarounds?