0
从数据库中获取pdf文件时出现错误。下面提到的是我的代码,请查看我的代码并给我提供宝贵的建议。并且它显示输出为无法打开该文件。请帮助我。在php中从数据库中获取pdf文件
<?php
$server = 'localhost';
$user = 'root';
$pass = '';
$db = 'upload';
// Connect to Database
$connection = mysql_connect($server, $user, $pass) or die ("Could not connect to server ... \n" . mysql_error());
mysql_select_db($db) or die ("Could not connect to database ... \n" . mysql_error());
$id = intval($_GET['id']);
$file= 'SELECT `name`,`size`, `created`,`data` FROM `upload`';
$result = mysql_query($file);
if($d = mysql_fetch_array($result))
{
$file = $d['name'];
header('Content-type: application/pdf');
header("Content-Disposition: inline; name=".$row['name']);
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . size($file));
header('Accept-Ranges: bytes');
header("Location: $file");
@readfile($file);
}
else{
echo'No file with the specified ID exists';
}
?>
未定义的变量:d在select.php上线14我得到错误像这样请帮助我。 – sudha
你试过我的第二个解决方案吗?这应该分配/定义$ d。 – infinigrove
直接去其他部分.... – sudha