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';
}
?>
未定義の変数をしようとするだろう。 – sudha
私の2番目の解決策を試しましたか? $ dを代入/定義する必要があります。 – infinigrove
それは他の部分に直接行っています.... – sudha