我尝试为每个循环上传多个文件。在这种情况下,我应该在move_uploaded_file()函数的第一个参数中使用什么
foreach ($_FILES["prodImg"]["name"] as $pImage) {
$nbr++;
$col = 'image' . $nbr;
$fileName = basename($pImage);
$target_file = $target_dir . "" . $fileName;
$rqt = "UPDATE prodimages SET $col=? WHERE prodId= ? ";
$stmt = $con->prepare($rqt);
$stmt->execute(array($fileName, $pID));
move_uploaded_file($pImage, $target_file);
}
答案 0 :(得分:2)
正如您在docs中所看到的,您可以使用$_FILES["prodImg"]["tmp_name"][$i]
:
foreach ($_FILES["prodImg"]["name"] as $i => $pImage) {
move_uploaded_file($_FILES["prodImg"]["tmp_name"][$i], /*..*/);
}
您可以随时var_dump($_FILES);
查看它的外观。