我无法将文件上传到数据库。我收到了这个错误:
警告:include(library / config.php):无法打开流:第32行的C:\ xampp \ htdocs \ mySE_project \ upload.php中没有此类文件或目录
这是下面的代码:
<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>
<?php
include_once("adb.php");
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
include 'library/config.php';
include 'library/opendb.php';
$query = "INSERT INTO fileUpload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($query) or die('Error, query failed');
include 'library/closedb.php';
echo "<br>File $fileName uploaded<br>";
}
?>
答案 0 :(得分:1)
错误
Warning: include(library/config.php): failed to open stream: No such file or directory in C:\xampp\htdocs\mySE_project\upload.php on line 32
显然提到在目录中找不到config.php文件。
答案 1 :(得分:0)
尝试更改为此并确保您拥有库文件夹中的文件。
include "../library/config.php";
include "../library/opendb.php";
或
include "./library/config.php";
include "./library/opendb.php";