Reputation: 325
i have this show uploaded pdf file on my localhost my view is
<?php
// retrieve your info ecc.
$url = $content->PATH;
$filename = $content->FILE_NAME;
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename. '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($url);
?>
just to be clear
$content->PATH
and $content->FILE_NAME
are data from database
$content->FILE_NAME
is $file_name = $file_data['file_name'];
and $content->PATH = base_url().'uploads/pdf/'.$file_name;
now it perfectly works on my localhost, but on the server, it looks like this
the link to this is
$row[] = '<a href = "http://146.88.72.53/CaloocanCity/PDFuploads/pdffile/'.$info->ID_NUM.'/'.$info->DOC_NO.'/'.$info->FILE_NAME.'" class = "btn btn-sm btn-info pull-left fa fa-question-circle" title="Show File">  Show File</a>";
what is the error of this ? how can i solve this?
Upvotes: 0
Views: 179
Reputation: 502
Try with CI built-in download helper class
$this->load->helper('download');
force_download($file_name);
Upvotes: 2