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 6177499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:17:14+00:00 2026-05-24T00:17:14+00:00

I would like to use this script to multiple file upload with jQuery v1.6.2.

  • 0

I would like to use this script to multiple file upload with jQuery v1.6.2. It works well with any version =< 1.3.2, but not with 1.4.x or newer.

Can you please help me to to make it work with 1.6.2?

when I select 3 files to upload, then I remove the first one; all input fields of the 2nd and the 3rd file got removed too. 🙁

(With jQuery v1.3.2 the the 2nd and the 3rd do not get removed.)

HTML:

<input type="file" class="upload" name="fileX[]" />
<div id="queue" class="queue"></div>

JavaScript:

$(document).ready(function () {

    $("input.upload").change(function () {
        validateFile(this);
    });


    function validateFile(myelement) {

        //$(myelement).hide();//disabled to test

        $(myelement).parent().prepend('<input type="file" class="upload" name="fileX[]" />').find("input").change(function () {
            validateFile(this)
        });
        var elementval = myelement.value;
        if (elementval != '') {
            $("#queue").append('<div>' + elementval + '&nbsp;&nbsp;<a class="remove">X</a></div>').find("a").live('click', function () {
                $(this).parent().remove();
                $(myelement).remove();
                return true;
            });
        }
    };

});
  • 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-24T00:17:15+00:00Added an answer on May 24, 2026 at 12:17 am

    I still can’t figure out why it’s removing all the inputs. I can only imagine it has to do with the myelement variable being bound to the live click event. We reuse this variable each time the input change function is called, and I’m not sure how jQuery handles this with those <a> click events. I think I’ll do some digging.

    I came up with a workaround, though.

    Instead of storing the element inside of the live event bound to the <a>, I gave the input and the queue div data-id‘s. So when #queue a gets clicked, it matches an input with its own data-id:

    $(document).ready(function () {
        var count = 0;
        $('input.upload').live('change', function() {
            $(this).parent().prepend('<input type="file" class="upload" name="fileX[]" />');
            $(this).attr('data-id', count);
            $('#queue').append('<div data-id="' + count + '">' + $(this).val() + '&nbsp;&nbsp;<a class="remove">X</a></div>');
            count++;
        });
        $('#queue div a').live('click', function() {
            $('input[data-id="' + $(this).parent().attr('data-id') + '"]').remove()
            $(this).parent().remove();
        });
    });         
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a seam app and would like to use the MultiPowUploader ( http://www.element-it.com/multiple-file-upload/flash-uploader.aspx
I would like to use VB9 but am not sure what syntax to use
Is there an openID implementation in Java? I would like to use this in
I would like to use a component that exposes the datasource property, but instead
I would like to use Emacs to edit some VB6 files but Emacs does
I have been trying to use an ajax-style file upload component (like the dojox
I am using Ruby on Rails 3 and I would like to use jQuery
I would like to use a language that I am familiar with - Java,
I would like to use something like CLR Profiles on .Net 2.0 to see
I would like to use as and is as members of an enumeration. I

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.