Codeigniter PDF File Upload
PDF File Upload Codeigniter Framework mostly discussed previously and this post is about uploading files in Codeigniter has upload library by using this class we can upload file on server very easily. Codeigniter session Storage
Codeigniter PDF File Upload |
<?php echo $error; echo form_open_multipart('upload/do_upload'); echo form_input(array('type' => 'file','name' => 'userfile')); echo form_submit('submit','upload'); echo form_close(); ?>
Controller method you need to set some config setting like uploading path, allowed types, upload sizes, width height,... etc.
function upload(){
$this->load->library('upload');
$config['upload_path'] = './assets/certificates/';
$config['allowed_types'] = 'pdf';
$config['max_size'] = '1000000';
$config['file_name'] = "upload";
$this->upload->initialize($config);
$certificateflag = $this->upload->do_upload("certificate");
if ($this->upload->do_upload("certificate"))
error_reporting(E_ALL);
else{
echo "<pre>"; Print_r($this->upload->data()); echo "</pre>";
}
}
<?php
Library Codeigniter PDF File upload root directory Follows
Open <root_directory>/system/application/config/mimes.php file
Change value of ‘pdf’ element of $mimes array
$mimes = array( ‘hqx’ => ‘application/mac-binhex40’,
‘cpt’ => ‘application/mac-compactpro’,
‘csv’ => array(‘text/x-comma-separated-values’, ‘text/comma-separated-values’, ‘application/octet-stream’, ‘application/vnd.ms-excel’, ‘text/csv’, ‘application/csv’, ‘application/excel’, ‘application/vnd.msexcel’),
‘bin’ => ‘application/macbinary’,
‘dms’ => ‘application/octet-stream’,
‘lha’ => ‘application/octet-stream’,
‘lzh’ => ‘application/octet-stream’,
‘exe’ => ‘application/octet-stream’,
‘class’ => ‘application/octet-stream’,
‘psd’ => ‘application/x-photoshop’,
‘so’ => ‘application/octet-stream’,
‘sea’ => ‘application/octet-stream’,
‘dll’ => ‘application/octet-stream’,
‘oda’ => ‘application/oda’,
‘pdf’ => array(‘application/pdf’, ‘application/x-pdf’),
To
‘pdf’ => array(‘application/pdf’, ‘application/x-pdf’, ‘application/x-download’,’application/x-download’, ‘binary/octet-stream’, ‘application/unknown’, ‘application/force-download’),
3 comments
commentseh kutu kupret , screenshott ama tutorialnya beda , kemplu lau
ReplyHello,
ReplyCan you explain in English. So that we will provide a solution for this.
Thanks
your sreenshoot diffrent with actual your coding man....
Reply