SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Raffles, I tried adding the following to my form:

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

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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).

    Quote Originally Posted by PHP Manual
    In php.ini, be sure you've set the the upload_max_filesize and post_max_size to be large enough to handle your upload.
    - In your httpd.conf (if you're using apache), check that the LimitRequestBody directive isn't set too low (it's optional, so it may not be there at all).

    If those settings don't work, you can check your firewall configuration. When uploading large files, packets have to be split into fragments of varying size depending on your systems MTU (maximum transmission unit), which is typically 1500 bytes.

  5. #5
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:
    Code:
    <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.

  6. #6
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 Have any thoughts on my original question or perhaps any other workarounds?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •