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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:21:09+00:00 2026-06-10T13:21:09+00:00

I am trying to create a dynamic multiple file upload system where the user

  • 0

I am trying to create a dynamic multiple file upload system where the user specifies the number of files to be uploaded. After the selection is made, the corresponding number of file upload fields are created and then the user can make the upload.

Below is the script that I have. From my debugging the array is created successfully, but the upload fails. I will really appreciate some help if someone tells me what I am doing wrong.

<form action="" method="post" enctype="application/x-www-form-urlencoded" name="max">
  <table width="100%" border="0" cellspacing="2" cellpadding="2">
    <tr>
      <td >no of products</td>
       <td><input name="max2" type="text" id="max2" size="3" maxlength="2" />
        </td>
      <td><input type="submit" name="go" id="go" value="go&gt;&gt;" /></td>
    </tr>
  </table>
</form>
<form action="" method="post" enctype="multipart/form-data" name="uploader" id="uploader"><table>
  <tr>
<td>

   <?php
global $max;
if(isset($_POST['max2']))
    $max = $_POST['max2'];
else
    $max = 3;

for ($i = 1; $i <= $max; $i++) {
$forms = '<table>
          <tr>
            <td>File</td>
            <td><label for="uploader"></label>
              <input name="uploader'.$i.'" type="file" id="uploader'.$i.'" /></td>
          </tr>
        </table>';
echo $forms.'<br>';//// creates a new form field depending on number of files specified by user
}
?>
 <input name="max3" type="hidden" id="max" value="<?php echo $_POST['max2'] ?>" />
 <?php
  if(isset($_POST['upload'])){

$uploadArray= array();
for ($i = 1;$i <= $_POST['max3']; $i++) {
$uploadArray[] = $_FILES['uploader'.$i]['name'];
        }
print_r ($uploadArray); // display array to check it was properly created


 foreach($uploadArray as $file) {

    $target_path = "../Users/storename/upload/";

        if(file_exists($target_path) && is_dir($target_path)){

                if(move_uploaded_file($_FILES[$file]["tmp_name"], $target_path.'new'.$file)) {
                     echo "<br> The file ".  basename( $_FILES['$file']['name'])." has been uploaded";
                } 
                else{
                    echo "<br>The file ".$file." has NOT been uploaded";
                }

    }
    else{
    echo 'invalid path<br>';
    echo $target_path;
    }
}
}

?></td>
     </tr>
  <tr>
   <td><input type="submit" name="upload" id="upload" value="Submit" /></td>
  </tr>
  </table>

</form>
  • 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-10T13:21:10+00:00Added an answer on June 10, 2026 at 1:21 pm

    If you are ready to use jquery try this for multiple uploads.

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

Sidebar

Related Questions

I am trying to create dynamic pages without creating new files and getting the
I'm trying to create a dynamic point system based off of how much money
I am trying to create a dynamic pagination system for my website and I've
I am trying to create a dynamic CSS file using the Django templating engine
I am trying to create dynamic menus from the database using the following example
i'm trying to create a Dynamic Sub-menu to use it in Wordpress, Something like
I am trying to create a dynamic 'page' listing for threads/comments using AJAX. in
I'm trying to create a dynamic regex to select URL's based on a segment
I'm trying to create a dynamic datagrid in Flex. The data is coming back
I am trying to create a dynamic hyperlink that depends on a value passed

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.