我遇到了一个问题,我可以将图像上传到我的服务器上的目录(不是本地主机),但它会生成一个名为“array”的文件,但在文件浏览器中具有正确的视觉效果。这是我的代码:
$ntitel = $_POST['titel'];
$npost = $_POST['bericht'];
$filetmp = $_FILES["file_image"]["temp_name"];
$filename = $_FILES["file_image"]["name"];
$filetype = $_FILES["file_image"]["type"];
$filepath = "../daphne.db/images/nieuwsplaatjes/".$filename;
move_uploaded_file($filetmp, $filename);
$ntitel = mysql_real_escape_string($ntitel);
$npost = mysql_real_escape_string($npost);
$query = "INSERT INTO nieuws (ntitel, npost, afb, afbtype, afbnaam) VALUES ('$ntitel', '$npost', '$filepath', '$filetype', '$filename');";
mysql_query($query);
echo "<h3>Je bericht is toegevoegt aan de Nieuws en Weetjes pagina!</h3>";
}
当然,我的连接位于此代码之前,但这是我认为重要的东西。
最佳答案
尝试使用:
$filename = $_FILES["file_image"]["name"][0];
对大小
和类型
也执行相同的操作。
在这里查看类似的帖子:http://board.phpbuilder.com/showthread.php?10333599-Upload-Image-Problem
关于php - 上传图片到主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27448662/