您好,感谢您对此代码的一些帮助。 它显示以下错误通知:
未定义的变量:文件路径 ™ C:''wamp''www''fileupload''post_listing.php 在第 20 行。
此外,它的显示
"您的 SQL 语法有误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近第 1 行的")"
这是代码
<?php require_once('libs/Conn_host.php'); ?>
<?php
if(isset($_POST['upload']))
{//you get the following information for each file:
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$target_dir = 'images/';
$filePath = $target_dir .$fileName;
$result = move_uploaded_file($tmpName, $filePath);
if($result) {
mysql_select_db($database_Conn_host, $Conn_host);
$query = "INSERT INTO images (name, size, type, path) "."VALUES ('$fileName', '$fileSize', '$fileType', '$filePath’)";
$rsUpload = mysql_query($query, $Conn_host) or die(mysql_error());
echo "Successful uploaded" .$fileName;
}
else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
我在路径方面也有类似的问题,我认为可能是错误的是您没有发送到正确的目录,请检查"images"所在的目录