我用PHP和msqli在我的phpMYadmin上传图片但是得到了提到的错误所以几乎所有东西都会插入除了image.I认为每件事都很好不知道问题在哪里请帮助:(
这是php:
<?php
if(isset($_POST['submit'])){
$Name=$_POST['Name'];
$Desc=$_POST['Desc'];
$Image=$_FILES['image']['tmp_name']; //get error in this line
echo $_FILES['image']['error'];//get error in this line
$sql="INSERT INTO `items`(`Name`,`Description`, `image`)
VALUES('$Name','$Desc','$Image')";
if(mysqli_query($con,$sql)){
echo "new record";
}
else{echo"Wrong";}
mysqli_close($con);
}
?>
html:
<form action="http://localhost/onlinesShop/newitem.php" method="POST" >
<table id='table_admin'>
<tbody>
<tr>
<td width="116" height="50" align="left">Name</td>
<td width="466"><input name="Name" type="text" id="Name" title="Name" maxlength="200"></td>
</tr>
<tr>
<td height="290">Description</td>
<td><textarea name="Desc" cols="40" rows="15" id="textarea"></textarea></td>
</tr>
<tr>
<td>Image</td>
<td width="80"><input type="file" name="image" id="fileField" ></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="Upload"></td>
</tr>
</tbody>
</form>
</table>
</div>