您好对此代码有所帮助。 它显示以下错误通知:
未定义的变量:filePath中的 第20行的C:\ wamp \ www \ fileupload \ post_listing.php。
另外,它显示
“您的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>
答案 0 :(得分:0)
我遇到类似路径的问题,我认为可能是错误的是你没有正确的目录,检查目录&#34; images&#34;位于