Reputation: 264
I'm trying to use the dropzone JS plugin, and PHP to upload multiple files and then output each file url.
I have this so far:
$upload_dir = 'files';
for($i=0; $i<count($_FILES['file']['tmp_name']); $i++) {
$tempFile = $_FILES['file']['tmp_name'][$i];
$uploadPath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $upload_dir . DIRECTORY_SEPARATOR;
$mainFile = $uploadPath.time().'-'. $_FILES['file']['name'][$i];
$mainFile_short = time().'-'. $_FILES['file']['name'][$i];
if(move_uploaded_file($tempFile,$mainFile)) {
}
}
I can't seem to make this work though, I'm not sure where I'm going wrong. Any ideas would be great!
Upvotes: 2
Views: 101
Reputation: 77
$img = $_FILES['file'];
$upload_dir = 'files';
if(!empty($img))
{
$img_desc = reArrayFiles($img);
print_r($img_desc);
foreach($img_desc as $val)
{
$tempFile = $val['tmp_name'];
$uploadPath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $upload_dir . DIRECTORY_SEPARATOR;
$mainFile = $uploadPath.time().'-'. $val['name'];
$mainFile_short = time().'-'. $val['name'];
if(move_uploaded_file($tempFile,$mainFile)) {
}
}
}
Upvotes: 1