Actually,I'm working on Codigniter adminpanel modules,i'm implemented a module i want give download link in separate column how will give please help.
1) i Want (**Files List**) column need to give download link.
Here my code : views.php
<table class="table table-hover" id="dataTables-tenant">
<thead>
<tr>
<th><input type="checkbox" data-note="tooltip" data-placement="top" data-original-title="Check/Uncheck all" class="check-all"></th>
<th>File Name</th>
<th>File title</th>
<th>Files List</th>
<th>created at</th>
<th>updated at</th>
<!-- <a href="http://localhost/fre/admin/uploads/" download="w3logo">
<img border="0" src="http://localhost/fre/admin/uploads/.'$Knowledge_id'" alt="W3Schools" width="104" height="142">
</a> -->
<th class="text-center">Actions</th>
</tr>
</thead>
</table>
Script :
<script type="text/javascript">
var oTable = $('#dataTables-tenant').dataTable( {
"bProcessing": true,
"sAjaxSource": "<?php echo base_url(); ?>loadTenant",
"pageLength": 10,
"aoColumnDefs" : [
{
orderable: false,
"mData": null,
"aaSorting":false,
"aTargets": [0],
"mRender": function (data, type, full) {
return '<input type="checkbox" value="'+full[0]+'" name="Knowledge_id" class="case selectionne uncheck"/>';
},
"sClass": 'selectall'
},
{
orderable: false,
"mData": null,
"aaSorting":false,
"aTargets": [6],
"mRender": function (data, type, full) {
return '<center><a href="<?php echo base_url(); ?>tenant/editNew/'+full[0]+'" data-note="tooltip" data-original-title="Edit Tenant Details" class="glyphicon glyphicon-edit" id="infrastructure_btn_edit"></a> <a href="#" data-note="tooltip" data-original-title="Delete Room" data-Knowledge_id="'+full[0]+'" class="glyphicon glyphicon-trash deleteTenant"></a></center>';
},
},
]
});
</script>
create download file in your project and send data to this file
for example:
download.php
<?php
// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$filename = "Perfomance_Appraisal.docx";
$objWriter->save($filename);
// The following offers file to user on client side: deletes temp version of file
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
flush();
// or echo($filename)
readfile($filename);
unlink($filename); // deletes the temporary file
You can also use the following library:
</div>