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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:21:39+00:00 2026-05-31T13:21:39+00:00

I am doing a file upload form with the following buttons: Choose file, Upload

  • 0

I am doing a file upload form with the following buttons: “Choose file”, “Upload” and “Add other file”

I am trying to remove the attribute “disabled” for Upload button when File Input change(). It works for the first Upload button, but not for the second Upload button and so on…
Why is that?

Thanks a lot if you could help me.

My jquery code is:

$(document).ready(function() {

$('input[type=file]').change(function(){
    $(this).next().removeAttr('disabled');
}); 

$('.add').click(function() {
    var num = $('input[type=file]').length; 

    newNum = num + 1;
    if (newNum >= 4){
        $('.add').hide();   
        }

    $('#addanother').append("<form method='POST'>");
    $('#photo1').clone().attr('id','photo'+newNum).appendTo('#addanother');
    $('#upload'+num).clone().attr('id','upload'+newNum).attr('disabled','disabled').appendTo('#addanother');
    $('#addanother').append('</form><br />');

    });
});

My html code is:

<form method='POST' enctype="multipart/form-data">
<input type='file' class='fileinput' id='photo1'>

<input type='button' id='upload1' name='upload1' value='Upload' disabled='disabled'>
</form>

<div id='addanother'></div>

<input type='button' class='add' id='add1' value='Add file'>
  • 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-31T13:21:40+00:00Added an answer on May 31, 2026 at 1:21 pm

    You are adding the 2nd upload button dynamically and so the event handler was not bound. Use .on in below syntax,

    $(document).on('change', 'input[type=file]', function(){
        $(this).next().removeAttr('disabled');
    }); 
    

    and remove,

    $('input[type=file]').change(function(){
        $(this).next().removeAttr('disabled');
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working Ajax form, now I'm trying to add file upload to
I have a file upload form set up with the HTML5 multiple attribute. However,
I'm doing a groovy/grails form file-upload operation, as is described here http://www.grails.org/File+Upload I'd like
I am doing file upload async with jquery/php using the target attribute of a
I'm trying to add a file upload script in php to a website I'm
I'm doing an ajax style file upload by posting the file in a form
I'm doing some form in Zend Framework for file upload on Apache friends -
I've been doing research on image file upload security for a while but can't
I've got the following HTML form. As you can see it's saving a file.
Hello I'm doing file upload with Yii. I have implemented this way and it

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.