如何修复此警告?
警告:file_get_contents()[function.file-get-contents]:第26行的C:\ xampp \ htdocs \ blob \ index.php中的文件名不能为空
“字段列表”中的未知列'值'
我只是从那开始,它充满了错误。
<?php
ini_set('mysql.connect_timeout', 300);
ini_set('default_socket_timeout', 300);
?>
<html>
<body>
<title>upload and view image</title>
<form method="POST" entype="multipart/form-data">
<br/>
<input type="file" name="image" />
<br/><br/>
<input type="submit" name="sumit" value="upload" />
</form>
<?php
if(isset($_POST["sumit"]))
{
if(isset($_POST["submit"]) && isset($_FILES['file']))
{
$file_temp = $_FILES['file']['tmp_name'];
$info = getimagesize($file_temp);
}
else
{
$image= addslashes($_FILES['images']['tmp_name']);
$name= addslashes($_FILES['images']['name']);
$image= file_get_contents($images);
$image= base64_encode($image);
saveimage($name,$image);
}
}
displayimage();
function saveimage($name,$image)
{
$con= mysql_connect("localhost","root","");
mysql_select_db("kstark", $con);
$qry= "insert into images(name,value) values ('$name','$image')";
$result= mysql_query($qry,$con);
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'];
}
if($result)
{
echo "<br/>Image Uploaded.";
}
else
{
echo "<br/>Image not Uploaded.";
}
}
function displayimage()
{
$con= mysql_connect("localhost","root","");
mysql_select_db("kstark", $con);
$qry= "select * images";
$result= mysql_query($qry,$con);
while($row = mysql_fetch_array($result))
{
echo '<img height="300" width="300" src="data:image;base64,'.$row[2].' ">';
}
mysql_close($con);
}
?>
</body>
</html>
答案 0 :(得分:0)
您使用此代码:
$image= file_get_contents($images);
但你的变量是$ image而不是$ images,也许你可以试试这个:
$image= file_get_contents($image);