Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6348507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:25:57+00:00 2026-05-24T21:25:57+00:00

I have a file upload form. When submitted, the form posts the data to

  • 0

I have a file upload form. When submitted, the form posts the data to an iframe and then uses jQuery and PECL UploadProgress to get the upload progress of the file. When the script requests the upload progress and the response is null, the file has finished uploading, the script then reads the iframe for information of the file.

The script runs in an interval which is cleared when the response is null.

My problem with the script is that, if the file uploads before the request to the files progress is made, an error will occur because the browser will try to get the value of the property which hasn’t been set (the response would be blank).

How can I check if the file has finished uploading before the script tries to get the value of a property which hasn’t been set?

Is there some way to add a listener of some sort to the iframe so when it finishes loading, I can immediately cancel the interval and display the result?

I have thought to check the content of the iframe before the request and if there is data, cancel the request and display the data, but it doesn’t seem to work.

Error I am getting in IE:

    Line: 37
    Error: Unable to get value of the property 'filename': object is null or undefined

Apologies in advance if this seems a little stupid, I haven’t slept yet working on this project and I can’t find a way to fix this.

function beginUpload()
{
    // Hide the upload form
    $("#uploadContainer").hide(function(){
        $(".fileProgress").show();
    });

    var interval = setInterval(function(){

        $.getJSON("upload.php?uploadProgressKey=" + uploadProgressKey, function(returnData){

            if($("#uploadFrame").contents().find("html body").html() !== "")
            {
                clearInterval(interval);
                $("#content").html($("#uploadFrame").contents().find("html body").html());
            }
            if(returnData == null)
            {
                // Upload complete as there is not data to report about upload
                // Stop the interval of checking the data
                clearInterval(interval);

                // Load result to content div
                $("#content").html($("#uploadFrame").contents().find("html body").html());
            }

            setUploadInformation(returnData.filename, returnData.bytes_uploaded, returnData.bytes_total, returnData.speed_average);
            setUploadBar(returnData.bytes_uploaded, returnData.bytes_total);
        });

    }, 800);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:25:57+00:00Added an answer on May 24, 2026 at 9:25 pm

    Don’t know if this going to work:

    function beginUpload() {
        // Hide the upload form
        $("#uploadContainer").hide(function(){
            $(".fileProgress").show();
        });
    
        var checkProgress = function () {
            $.getJSON("upload.php?uploadProgressKey=" + uploadProgressKey, function(returnData){
    
                if($("#uploadFrame").contents().find("html body").html() !== "") {
                    clearInterval(interval);
                    $("#content").html($("#uploadFrame").contents().find("html body").html());
                }
                if(returnData == null) {
                    // Upload complete as there is not data to report about upload
                    // Stop the interval of checking the data
                    clearInterval(interval);
    
                    // Load result to content div
                    $("#content").html($("#uploadFrame").contents().find("html body").html());
                }
    
                setUploadInformation(returnData.filename, returnData.bytes_uploaded, returnData.bytes_total, returnData.speed_average);
                setUploadBar(returnData.bytes_uploaded, returnData.bytes_total);
            });
    
        }
        var interval = setInterval(checkProgress, 800);
        checkProgress();
    }
    

    Your interval first starts after 800ms. I Created the function checkProgress and call it right after you initialize the interval. This way you start checking all at once.

    Still i think you can meet the same bug if the first AJAX call (getJSON) is done after the upload?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method set up that uses jquery form for a file upload
i have a upload file form and a iframe. form is submitted to a
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file
I have a file upload form that is being posted back to a servlet
We have got an extjs 3.1.1 form with file upload field ( http://www.extjs.com/deploy/dev/examples/form/file-upload.html from
I have an upload form with a file to be uploaded. The issue I
I have a form that excepts a file upload in ASP.NET. I need to
I have a form which binds a model and a file upload using the
I have a form where the user can upload a zip file, it works
I have a upload file form, when you hit Submit it send the file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.