我正在尝试将多个pdf文件上传到我网站的文件夹中。它只上传了pdf中的第一个pdf,所以我试图使用一个数组,但它给出了一个错误。
$target = "../media/covers/".basename($_FILES['image']['name']);
$pdf_target = "../media/pdfs/".basename($_FILES['pdf_file']['name'][0]);
// I use [0] above to access the string
foreach($pdf as $idx){
if (isset($_POST["upload"])) {
if(move_uploaded_file($_FILES['image']['tmp_name'], $target)
&& move_uploaded_file($_FILES['pdf_file']['tmp_name'][$idx], $pdf_target)){
$msg = "image uploaded";
} else {
$msg = "There was a problem uploading image";
}
}
}
我希望所有文件都上传到文件夹“../media / pdfs /”