无法使用php和Jquery打开PDF文件
在我的情况下,无法显示所有pdf文件,有些pdf可以在浏览器上查看,有些无法查看,尝试回显pdf文件,但始终不工作,顺便说一下,我上传的所有文件都上传到MySql Database中。。我不使用文件夹移动上载的文件。。请参阅我的jquery代码和php代码无法使用php和Jquery打开PDF文件,php,jquery,Php,Jquery,在我的情况下,无法显示所有pdf文件,有些pdf可以在浏览器上查看,有些无法查看,尝试回显pdf文件,但始终不工作,顺便说一下,我上传的所有文件都上传到MySql Database中。。我不使用文件夹移动上载的文件。。请参阅我的jquery代码和php代码 $.ajax({ url:'fetchAllAttachenemts.php', method:
$.ajax({
url:'fetchAllAttachenemts.php',
method:'POST',
data:{DispID:DispID},
success:function(data)
{
if ( data == '')
{
$('#AttachementTable tbody' ).html( ' <tr> <td></td><td>No Files Were Uploaded</td><td></td></tr>');
}
else
{
$('#AttachementTable tbody' ).html(data);
}
},
error:function(data)
{
alert(data);
}
});
include 'connect.php';
global $con;
if (isset($_GET['id']))
{
$ID = $_GET['id'];
$stat = $con->prepare("SELECT * FROM dispatchattachmnt WHERE ID = ? ");
$stat->bindParam(1,$ID);
$stat->execute();
$row = $stat->fetch();
$file = $row['fileName'];
$filename = $row['fileName'];
header('Content-type: '.$row['fileMimi']); // = header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
//echo (@readfile($file));
echo $row['data'] ; // from blob in mysql
}
else
{
echo "NOT SET";
}
她是我去拿附件的密码
session_start();
include 'connect.php';
global $con;
$outpout='';
$ID= "";
if (isset($_POST['DispID']))
{
if($_POST['DispID'] !="")
{
$id = $_POST['DispID'];
$query= "SELECT * FROM dispatchattachmnt WHERE dispID = ?";
$stmt = $con->prepare($query);
$stmt->execute(array($id));
$result = $stmt->fetchAll();
$count = $stmt->rowCount();
if ($count >0)
{
foreach ($result as $row)
{
$outpout .= '<tr>';
$outpout .= '<td id = "'.$row['ID'].'" style="cursor:pointer"> <span class="modifyAttacheDesc"> '.$row['disc'].' </span></td> ';
$ID = trim($row['ID']);
$outpout .= '<td id = "'.$row['ID'].'" class="openAtt"> <a target="_blank" href="viewAttachement.php?id='.$row['ID'].'">'.$row['fileName'].'</a></td>';
$outpout .= '<td id = "'.$row['ID'].'" ><i id ="'.$row['ID'].'" class="fas fa-trash-alt task-icon2" </i></td>';
$outpout .='</tr>';
}
echo $outpout;
}
}
}```
您可能希望将长度发送到客户端标题内容长度:。strlen$目录;你能更新一下这个密码吗。。您的意思是标题“Content-length:”.strlen$filename“;不工作否它应该是数据长度headerContent长度:。strlen$row['data']我刚试过。。不工作你是怎么储存的?你确定,数据库中的数据是正确的吗?