在单页中如何相互使用两个move_uploaded_file函数。
答案 0 :(得分:1)
您不能在move_upload_file函数中嵌套,但可以将它们嵌套在for循环中。
<html>
<body>
<form>
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
</form>
</body>
</html>
<?php
$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");
}
}
?>
答案 1 :(得分:0)