我尝试使用dropzone JS插件,并使用PHP上传多个文件,然后输出每个文件网址。
到目前为止,我有这个:
$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)) {
}
}
我似乎无法做到这一点,我不知道自己哪里出错了。任何想法都会很棒!
答案 0 :(得分:1)
$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)) {
}
}
}