我有一个 MySQL 数据库,它有几个指向 pdf 文件的 url(如 path/.../file.pdf),我想在浏览器中将它们显示为 jpeg 图像。我浏览了整个网络,但找不到解决方案。有谁知道如何做到这一点?任何帮助表示赞赏。目前我有两个文件:index.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<meta http-equiv="Content-Type" content="application/pdf; charset=UTF-8">
<title>Something</title>
</head>
<body>
<h1 align="center">Something</h1>
<img src="newindex.php" alt=" image" /></body></html>
和newindex.php:
<?php
header('Content-type: image/pdf;');
$con = mysql_connect("someurl",
"xxx","xxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxx", $con)or die("cannot select DB");
$result = mysql_query("SELECT pdfurl FROM TABLE_NAME WHERE Code LIKE 'YY'");
if($result === FALSE) {
echo "nooooo";
}
echo "hey";
while($row = mysql_fetch_array($result))
{
echo '<img name="myimage" src="'.$row['pdfurl'].'" width="60" height="60" alt="word" />';
}
mysql_free_result($result);
mysql_close($con); ?>