我想上載圖像到數據庫,圖像只會在用戶回顯時發出,但它不起作用,並且不會給我任何錯誤使用php上傳圖像到數據庫
<?php
session_start();
$pic = $_FILES['pic'];
$submit = $_POST['post'];
$user = $_SESSION['username'];
if($submit){
$connect = mysql_connect("localhost", "root", "123");
if($connect){
$database = mysql_select_db("phplogin");
if($database){
mysql_query("INSERT INTO images(image, user) VALUES ($pic, $user)");
$query = mysql_query("SELECT * FROM images WHERE user = '$user'");
$data2 = mysql_fetch_array($query);
header("Content-type: image/jpeg");
echo $data2['image'];
} else {
die("Couldn't connect to the database please try again, if you fail to connect again please contact me");
}
} else {
die("Couldn't connect to the database please try again, if you fail to connect again please contact me");
}
}
?>
您的'$ pic'變量是文件項目的信息數組,它只是一個關於文件的信息數組而不是實際的文件內容 –
如何使它成爲文件內容 – user3470226
瞭解如何進行基本調試。 – CBroe