$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
}
}
一次拍摄,如何在两个地方上传图像。一个进拇指文件夹另一个进入实际图像文件夹。
注意:不是多文件上传。
答案 0 :(得分:1)
move_uploaded_file()
已将文件移至$target_path
路径。所以,你的临时没有任何东西,第二次使用copy()
。命令上传它。
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
if (!move_uploaded_file($tmp_name,$uploads_dir/$name)) {
throw new Exception('Could not move file');
}
if (!copy($uploads_dir/$name, $target_path1)) {
throw new Exception('Could not move 2nd file');
}
}
}