我想通過使用php的web窗體插入到mysql數據庫的小圖像。但它不起作用。怎麼了?試圖插入圖像到blob字段
形式:圖像
<form action="http://www.yeahthatrocks.com/update2.php" method="post" enctype="multipart/form-data">
Game Name: <input name="game_name" type="text" size="25" maxlength="255" /><br></br>
Release Date: <input name="release_date" type="text" size="25" /><p></p>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
Cover Image: <input type="file" name="cover" id="cover"><br><br>
<input name="upload" type="submit" id="upload" value="upload" />
</form>
插入查詢:
$fileName = $_FILES['cover']['name'];
$tmpName = $_FILES['cover']['tmp_name'];
$fileSize = $_FILES['cover']['size'];
$fileType = $_FILES['cover']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$query = "INSERT INTO games set name='".$fileName."', size='".$fileSize."', type='".$fileType."', content='".$content."'";
mysql_query($query) ;
我是半個傾斜問你,如果你的電腦開啓時:)你得到一些錯誤訊息? – aib
是的電腦在...大聲笑。沒有錯誤信息,只是沒有文件上傳。 –