我有这段代码。我的目标是通过使用PHP将图像上传到MySQL。这给出了错误:404。我一遍又一遍地检查了我的代码,但没有看起来错误。 mysqli_connection有什么问题,我尝试上传其他内容,并且工作正常,但对于图像我有一个问题,错误:404。任何人都有什么想法,这里有什么问题? 注:当前文件的名称是upload.php的php image上传到mysql
<html>
<head>
<meta charset="UTF-8">
<title>Resim Yükleyiniz</title> //Upload and image
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="resim" value="Resim Seçiniz"> <input type="submit" value="Yükle"> //choose an image , upload
</form>
</body>
<?php
//getting mysqli connection
$con = mysqli_connect("mysql.hostinger.web.tr","*******-user","*****-password") or die(mysql_error());
mysqli_select_db($con,"********-database name") or die(mysql_error());
$ders = $_GET['ders'];
//getting file content
$dosya = $_FILES['resim']['tmp_name'];
if(isset($dosya)){
$resim = addslashes(file_get_contents($_FILES['resim']['tmp_name']));
//control of if the file is an image or not
$resim_boyutu = getimagesize($_FILES['resim']['tmp_name']); //This gives false if the $dosya is not an image
if($resim_boyutu == false)
echo "Lütfen resim türünden bir dosya seçiniz.";
else {
if(!mysqli_query($con,"INSERT INTO $ders VALUES ('','$resim')")) //uploading image into the table
echo "Görüntü yüklenirken bir hata oluştu.";
else
echo "Görüntü yüklendi";
}
}
else
echo "Lütfen resim seçiniz.";
?>
</html>
你在print_r($ _ FILES)中得到了什么?图像名称中是否有任何保留字符(例如空格,标点符号,非ASCII)? – Bhavin
有_mat_upload.php_ – Ayak973
@ Ayak973啊真的非常感谢!!!我已经改变了一个.php文件名,但忘了改变它的连接。我已经给了很多时间来解决这个问题..小虫子.. –