我正在使用jQuery插件--Galleriffic(link here)
我也在关注本教程:Upload Files To Database
好的,图片现在在数据库中,但是我无法使用这个来查看数据库中的图像:
<img src="getpicture.php?fid=1">
我在这里缺少什么?
答案 0 :(得分:1)
您是否将标头设置为
header("Content-Type: image/jpeg")
用于测试调用URL
getpicture.php?fid=1
看看会发生什么?
编辑:在第5步
<?
if(isset($_GET['fid']))
{
// connect to the database
include "connect.php";
// query the server for the picture
$fid = $_GET['fid'];
$query = "SELECT * FROM files WHERE fid = '$fid'";
print $query;
$result = mysql_query($query) or die(mysql_error());
print_r($result);
// define results into variables
$name=mysql_result($result,0,"name");
$size=mysql_result($result,0,"size");
$type=mysql_result($result,0,"type");
$content=mysql_result($result,0,"content");
print "check point 1 => $name, $size, $type, $content";
// give our picture the proper headers...otherwise our page will be confused
header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
echo $content;
mysql_close();
}else{
die("No file ID given...");
}
?>
替换上面的代码并从浏览器调用并查看其打印内容?
答案 1 :(得分:0)
on getpicture.php
header("Content-Type: image/jpeg")