[英]How to open a pdf located in a root folder in codeigniter without downloading the file?
我是Codeigniter的新手。 我在一個可以上載和查看PDF文件的網站上工作。 我已經成功上傳了。
問題是,每當我要在瀏覽器中查看上載的文件時,它都會自動下載。 我想在瀏覽器中查看PDF文件。 我該怎么做?
這是我的視圖中的代碼
<?php
echo '<table class = "table table-striped">';
echo '<tr>';
echo '<th class="table_head">Filename</th>';
echo '<th class="table_head">Department</th>';
echo '<th class="table_head">Uploaded by</th>';
echo '<th class="table_head"></th>';
echo '</tr>';
if(isset($tbl_uploaded) && is_array($tbl_uploaded) && count($tbl_uploaded) > 0)
{
foreach($tbl_uploaded as $uploaded)
{
echo '<tr>';
echo '<td>'. $uploaded->name .'</td>';
echo '<td>'. $uploaded->department .'</td>';
echo '<td>'. $uploaded->uploader .'</td>';
echo '<td><a href="'. base_url().'uploads/'.$uploaded->name .'" target="_new">View</a></td>';
echo '</tr>';
}
}
echo '</table>';
?>
在此先感謝大家
您必須更改瀏覽器設置。如果您使用的是firefox,只需轉到打開菜單,然后選擇選項->應用程序,然后選擇可移植文檔格式(pdf)操作以在firefox中設置預覽。
您可以嘗試一下,我正在使用此代碼從數據庫中生成一封信,我也在使用一個Codeigniter。
function createPDF()
{
$data['']= $this->input->post("");
$this->load->library('mpdf');
$this->load->model('');
$query = $this->'your_model'->'model_name'($data);
if($query!=null)
{
$hello .=' Insert your letter here
<p>' .$data->something. '</p> //fetch something from your database';
$mpdf=new mPDF('ISO-8859-1','letter', 10, 'Arial', 15, 15, 16, 16, 9, 9, 'P');
$stylesheet = file_get_contents(base_url().'css/pdf.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->SetHTMLHeader('<img src="'.base_url().'css/edrsletter.jpg"></img>');
$mpdf->WriteHTML($hello);
$mpdf->SetFooter(' Sample PDF template - {PAGENO}');
$mpdf->Output();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.