troubleshooting Question

Multiple files upload form

Avatar of jebbie635
jebbie635 asked on
PHP
5 Comments1 Solution362 ViewsLast Modified:
Hi experts,

I am using this form to upload multiple files and need a script to add more fields if needed, or one that uploads every file from a selected folder.

Thanks.

<html>
<head>
<title>HTML Upload Form</title>
</head>
<body>
<form action="load.php" method="post" enctype="multipart/form-data">
<table
<tr><th>
<input type="file" name="files[]" /><br />
<input type="file" name="files[]" /><br />
<input type="file" name="files[]" /><br />
<input type="file" name="files[]" /><br />
<input type="file" name="files[]" /><br />
</th><th>
<input type="file" name="files[]" /><br />
<input type="file" name="files[]" /><br />
<input type="file" name="files[]" /><br />
<input type="file" name="files[]" /><br />
<input type="file" name="files[]" /><br />
</th></tr>
<tr><td colspan="2"><input type="submit" value="Send" /></td></tr>
</form>
</body>
</html>

<?php
//places files into same dir as form resides
foreach ($_FILES["files"]["error"] as $key => $error) {
   if ($error == UPLOAD_ERR_OK) {
       echo"$error_codes[$error]";
       move_uploaded_file(
         $_FILES["files"]["tmp_name"][$key], 
         $_FILES["files"]["name"][$key] 
       ) or die("Problems with upload");
   }
}
?>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros