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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:28:44+00:00 2026-05-25T10:28:44+00:00

<?php $uploadNeed=3 ; for($i=0;$i<$uploadNeed;$i++) { ?> <div class=smWidth> <input type=file name=upload_file value= id= OnClick=alert(

  • 0
<?php $uploadNeed=3 ; for($i=0;$i<$uploadNeed;$i++) { ?>
    <div class="smWidth">
        <input type="file" name="upload_file" value="" id=" " OnClick="alert("
        2 ");" />
        <br />
        <div class="clear">
        </div>
    </div>
    <?php } ?>

I am able to create three file upload fields, but i want to add a new input file filed only when i select a file…. it should keep on increasing…. something like Facebook style file upload where you select a file for the first field, then the next popup’s…

I am actually checking for click event of browse, but it does not work…

  • 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-25T10:28:44+00:00Added an answer on May 25, 2026 at 10:28 am

    Here is a very basic pure-JS implementation – hopefully it will give you a nudge in the right direction…

    <script type="text/javascript">
    
      // This keeps track of how many inputs there are, because each one MUST have a unique name!
      var inputCounter = 1;
    
      function inputChange() {
    
        // This function will add a new input element, in a div, as it is in your
        // original code, every time it is called. We attach it to the onchange
        // event of all the inputs
    
        // Declare local variables and increment input counter (for input names)
        var newContainerDiv, newClearDiv, newInput, newBr;
        inputCounter++;
    
        // Create the new elements and set their properties
        newContainerDiv = document.createElement('div');
        newContainerDiv.className = 'smWidth';
        newInput = document.createElement('input');
        newInput.type = 'file';
        newInput.name = 'upload_file_'+inputCounter;
        newInput.onchange = inputChange;
        newBr = document.createElement('br');
        newClearDiv = document.createElement('div');
        newClearDiv.className = 'clear';
    
        // Add the new elements to the DOM
        newContainerDiv.appendChild(newInput);
        newContainerDiv.appendChild(newBr);
        newContainerDiv.appendChild(newClearDiv);
        document.getElementById('uploads_container').appendChild(newContainerDiv);
    
      }
    
    </script>
    
    <!-- just create one input at first, so we don't need the PHP loop any more -->
    
    <div id="uploads_container">
      <!-- we wrap it all in an outer container div with an id, to ease the task of adding more elements -->
      <div class="smWidth">
        <input type="file" name="upload_file_1" onchange="inputChange();" />
        <br />
        <div class="clear">
        </div>
      </div>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html input field, such as <form method=post action=process.php enctype=multipart/form-data> <div> <h3>Files:</h3>
PHP stores its session information on the file system of the host of the
I have a simple table for reference page: id name description image In reference.php,
when my ajaxupload script finishes it adds a read-only input w/ the value of
How do I detect if an uploaded file is an image using PHP? I
i just uploaded my php file to my new server, i want to check
I installed XAMPP a couple of days ago. I uploaded a PHP file to
Quick question; I replaced a .css file which I was referencing in html/php that
I have a file input element which generate by ajax/jquery.load(). and when I want
Is there any way for a php script to choose the name for a

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.