gpt4 book ai didi

javascript - 多次上传 PHP

转载 作者:行者123 更新时间:2023-11-28 01:05:18 25 4
gpt4 key购买 nike

我正在尝试使用 dropzone JS 插件和 PHP 上传多个文件,然后输出每个文件的 url。

到目前为止我有这个:

  $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)) {
}
}

虽然我似乎无法完成这项工作,但我不确定我哪里出错了。任何想法都会很棒!

最佳答案

$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)) {
}
}
}

关于javascript - 多次上传 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40046379/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com