-1
我想保留一個按鈕來下載pdf文件。但庫文件顯示在視圖中。有人請幫助我。提前感謝。 控制器代碼:如何在codeigniter中包含pdf下載
public function pdf()
{
//load library
$this->load->library('pdf');
$pdf = $this->pdf->load();
// retrieve data from model
$data['DocFile'] = $this->Docauth->get_items();
$data['DocFileName'] = "items";
ini_set('memory_limit', '256M');
// boost the memory limit if it's low ;)
$html = $this->load->view('Docauth_v', $data, true);
// render the view into HTML
$pdf->WriteHTML($html); // write the HTML into the PDF
$output = 'Docauth' . date('Y_m_d_H_i_s') . '_.pdf';
$pdf->Output("$output", 'I'); // save to file because we can
exit();
視圖文件
<div class="form-group">
<label class="control-label col-md-3">View File</label>
<div class="col-md-5">
<input name="DocFile" id="DocFile" class="form-control"` type="text" >
</div>
<a href="Docauth/pdf"><span class="glyphicon glyphicon-plus"></span></a>
</div>
https://stackoverflow.com/questions/30615451/download-a-pdf-file-instead -of-displays-it-with-codeigniter – RiggsFolly
您是否嘗試在輸出之前發送頭信息(content-type,content-disposition)? – BenRoob
更重要的是,你嘗試過谷歌搜索'「pdf下載codeigniter」'。它確實產生了大約1,000,000個東西供您查看 – RiggsFolly