Jump to content

multiple file upload


Recommended Posts

You can have a look at how I solved my problem: http://www.phpfreaks.com/forums/index.php/topic,299376.0.html,

it's not perfect, but it'll get you started... Just make sure you have permissions to upload into that folder...

You can also take a look at the PHP Manual, just search for multiple file upload...

I've used http://swfupload/ quite a bit - if you're needing this to be something that you'll do on a regular basis and want to have some automation in the processing, or if and end-user will be doing these uploads, I'd recommend it.  It allows you to upload multiple images at a time, gives you the ability to display a progress bar as they are uploading, and delivers them one at a time to your PHP script.  You need to work with the javascript but you technically can use the sample codes to get a pretty decent uploader.

Should be something like

<form method="post" target="server" action="upload.php" enctype="multipart/form-data">
<div>file1: <input size="50" type="file" name="files[]" /> </div>
<div>file2: <input size="50" type="file" name="files[]" /> </div>
<div>file3: <input size="50" type="file" name="files[]" /> </div>
...
<input type="submit" value="upload" />
</form>

 

# upload.php
for($i=0, $n=count($_FILES['files']['name']);$i<$n;++$i){
  if (false == my_upload_file($_FILES['files']['tmp_name'][$i], ...)){ 
    error_log($_FILES['files']['error'][$i]);  
  }
}

 

You should also check if e.g. $_FILES['files']['name'] is array

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.