include "host.php";
$name = $_POST['name'];
$size = $_FILES["files"]["size"];
$type = $_FILES["files"]["type"];
$error = $_FILES["files"]["error"];
$lista = $_FILES["files"]["name"];
foreach ($lista as $nome_immagine) {
$file = basename($nome_immagine);
$uploadfile = "photo1/$file";
echo $uploadfile;
$temp = $_FILES["files"]["tmp_name"];
mysql_query("INSERT INTO prova (gruppo, img) VALUES ('$name', '$file')") or die(mysql_error());
move_uploaded_file($temp, $uploadfile);
error_reporting(E_ALL);
}
### Chiudiamo il Database ###
mysql_close($conn_host);
这是一个上传多个文件。 给我这个错误:
注意:数组到字符串转换为...
此处:move_uploaded_file($ temp,$ uploadfile);
为什么?
答案 0 :(得分:0)
由于您上传的是多个文件,$_FILES["files"]["tmp_name"]
是一个数组,因此您需要像所有其他$_FILES
元素一样对其进行索引。
foreach ($lista as $index => $nome_immagine) {
$file = basename($nome_immagine);
$uploadfile = "photo1/$file";
echo $uploadfile;
$temp = $_FILES["files"]["tmp_name"][$index];
mysql_query("INSERT INTO prova (gruppo, img) VALUES ('$name', '$file')") or die(mysql_error());
move_uploaded_file($temp, $uploadfile);
error_reporting(E_ALL);
}