我想上传图像到MySQL表。当图像选择它工作正常。但是,如果没有选择图像,则显示错误信息。我该如何解决它?图像上传到MySQL数据库使用PHP
警告:file_get_contents()函数:文件名不能在 C是空的:\ WAMP \ WWW \ firstdialnew \ firstdial \ adhandler.php上线23
$stype=$_POST['stype'];
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
if($stype="")
{
echo "Please fill all the details";
}else{
$sql=mysql_query("INSERT INTO ads
(sid,stype,image,image_name)
VALUES(NULL,'$stype','$image','$image_name')");
echo "Details Successfully send";
}
消息很明显,你没有任何$ _FILES,显示你上传文件的部分 – Mihai 2014-09-26 09:59:18
你试过倾销你的$ _FILES数组的内容 - 看起来你有阵列中没有什么这就是为什么你会得到这个消息 – Alex 2014-09-26 09:59:41
这是一个更好的主意,保持图像在服务器中,并在数据库中存储路径。 – 2014-09-26 10:01:51