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

  • SEARCH
  • Home
  • 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 8718947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:40:13+00:00 2026-06-13T06:40:13+00:00

To upload multiple files, I am using JavaScript to loop through the files. To

  • 0

To upload multiple files, I am using JavaScript to loop through the files.
To upload the files I am using the jQuery form plugin http://archive.plugins.jquery.com/project/form

Now, when the loop runs through, it runs to the end of the loop instantly, and uploads all files in one go.

Is there a way to get the loop to hold off during each upload?

This is an example of the loop im using (the actual code is quite large)

for(i=0;i<=num;i++)
{
    if(go1){
        <?php //if 1 upload only, hide add and upload button ?>
        $('#ad,#ok').hide();
        var z=i;
        $('#up'+i).ajaxSubmit({
            dataType:"json",
            beforeSubmit:function(before){
                $('#loadingsignup').show;
                $("#resultsignup").empty().hide();
            },
            success:function(retour){
                res=retour;
                if(num<1){  <?php // only one upload, redirect if uploaded correct, reintroduce upload button if error ?>
                    if(res.ok=="ok"){
                        window.location.replace('<?php echo $config['baseurl']; ?>/player/'+res.aid);
                    }else{
                        $('#rs'+z).append('<div class="pasgood">'+res.err+'</div>').show();
                        $('#ad,#ok').show();
                    }
                }
            }
        }); 

    }
}

I really need the loop to move through the uploads one at a time.

  • 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-06-13T06:40:14+00:00Added an answer on June 13, 2026 at 6:40 am

    No, the loop is synchronous while the upload is asynchronous. If you want the uploads to happen one after the other, you will need to fire the second one from the success callback of the first one etc.

    function upload(i, suc, err) {
        if (i > num)
            return suc();
        $('#up'+i).ajaxSubmit({
            dataType:"json",
            beforeSubmit:function(before){
                $('#loadingsignup').show();
                $("#resultsignup").empty().hide();
            },
            success:function(res){
                if(res.ok=="ok"){
                    $('#ad,#ok').show();
                    upload(i+1, suc, err); // next one
                } else {
                    $('#rs'+i).append('<div class="pasgood">'+res.err+'</div>').show();
                    err(res.err); // or continue with the rest?
                }
            },
            error: err
        });
    }
    upload(0, function allDone(){
        window.location.replace('<?php echo $config['baseurl']; ?>/player/');
    }, function somethingWrong(){ … });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the jQuery multi-file upload plugin found here: http://www.fyneworks.com/jquery/multiple-file-upload/ I don't see in
I'm using this plugin to upload multiple files with jquery, and this project is
I'm using the uploadify jquery plugin to upload multiple files. Everything works fine, but
I am using uploadify plugin of jquery and have set multiple files upload to
I am using plupload plugin to upload multiple files. That works fine. In Files
Is it possible to upload a whole folder instead of multiple files using Javascript?
I would like to upload multiple files using a single form field via Python
I am using 'Uploadify' Jquery plugin in my MVC 3.0 application to upload multiple
I am using SWFUpload to upload multiple files at once. But I notices that
I want to upload multiple files using java: are there any articles on the

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.