每次加载页面都会得到
分析错误:语法错误,在C:''examplep''htdocs''ZeroWebsite''uploadtest.php的第19行出现意外的")"
<html>
<head>
<title></title>
</head>
<body>
<form action="uploadtest.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image"> <input type="submit" value="Upload">
</form>
<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("dataimage") or die (mysql_error());
$file = $_FILES['image']['tmp_name']);
if (!isset($file))
echo "select an image";
else // this is my line 19
{
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
if ($image_size==FALSE)
echo "not a image.";
else
{
if (!$insert = mysql_query("INSERT INTO myimage VALUES ('','@image_name','$image')"))
echo "problem uploading image.";
else
{
$lastid = mysql_insert_id();
echo "image uploaded.<p /> Your image:<p />img src=uploadtest2.php?id=lastid>";
}
}
}?>
</body>
</html>
我在youtube上资助了这个指南,我只是想让它发挥作用,plzz告诉我该怎么做
$file = $_FILES['image']['tmp_name']);
必须是
$file = $_FILES['image']['tmp_name'];
更改
$file = $_FILES['image']['tmp_name']);
至
$file = $_FILES['image']['tmp_name'];
另外一个")"是他们的。
这是问题$file = $_FILES['image']['tmp_name']);
。删除最后一个)
,它就工作了。