Home arrow PHP arrow Page 3 - Creating a Multi-File Upload Script in PHP

Creating a Multi-File Upload Script in PHP

Frustrated with single-file upload scripts? Looking for an alternate route? Read as Jonathan shows us how easy it really is to setup a multi-file upload script using PHP.

Author Info:
By: Jonathan Wichmann
Rating: 4 stars4 stars4 stars4 stars4 stars / 730
October 27, 2003
  1. · Creating a Multi-File Upload Script in PHP
  2. · Script 1: Number of Upload Boxes Required
  3. · Script 2: Creating the Dynamic Form
  4. · Script 3: The Big Copy Bang Page
  5. · Conclusion

print this article

Creating a Multi-File Upload Script in PHP - Script 2: Creating the Dynamic Form
(Page 3 of 5 )


Ok, this page will be doing one half of the work. We will be using the for loop to get this task done.

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<form name="form1" enctype="multipart/form-data" method="post" action="processFiles.php">
  // start of dynamic form
  $uploadNeed = $_POST['uploadNeed'];
    <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
  // end of for loop
  <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
    <input type="submit" name="Submit" value="Submit">

In this page, all I did was create a simple HTML form with the value of the attribute "type" set to "file". Within the form I put a block of code to start the for loop. I set $x to 0 and I made it stop at the desired need by setting $x to be less than $uploadNeed – the value specified by the user. I also echo the $uploadNeed into a hidden input field to be carried over to the last page.

The key to making this all work however is the $x variable I am echoing right next to the uploadFile name. What this will do is append a number starting with 0 to the name. This in turn will make each upload field’s name unique.

blog comments powered by Disqus

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials