Welcome Guest, Not a member yet? Register   Sign In
File Upload. Everything I upload has mime octet-stream
#1

[eluser]Unknown[/eluser]
I am using uploadify with codeigniter and when uploading, I keep getting "File type is not allowed". Upon error I am printing the files current type, and everything I upload is showing "oectet-stream".

views/upload.php

Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;

&lt;link href="&lt;?php echo base_url() ?&gt;assets/uploadify/uploadify.css" type="text/css" rel="stylesheet"&gt;

[removed][removed]
[removed][removed]
[removed][removed]

[removed]
  $(document).ready(function() {
   $('#file_upload').uploadify({
    'uploader'   : '&lt;?php echo base_url() ?&gt;assets/uploadify/uploadify.swf',
    'script'   : '&lt;?php echo site_url('upload/do_upload') ?&gt;',
    'cancelImg'  : '&lt;?php echo base_url() ?&gt;assets/uploadify/cancel.png',
    'auto'    : true,
    'fileDataName' : 'userfile',
    'onComplete' : function(a, b, c, d, e){
                    if (d !== '1') {alert(d);}
                    else { alert('Filename: ' + c.name + ' was uploaded');}
                  }
   });
  });
  
  
[removed]

&lt;/head&gt;
&lt;body&gt;

&lt;input id="file_upload" name="file_upload" type="file"&gt;

&lt;/body&gt;
&lt;/html&gt;

controllers/upload.php

Code:
&lt;?php

class Upload extends CI_Controller {

  public function __construct() {
   parent::__construct();
   $this->load->helper('url');
  }

  public function index() {
   $this->load->view('upload');
  }
  
  public function do_upload() {
   $config['upload_path'] = '/tmp/';
   $config['max_size'] = '10000';
   $config['allowed_types'] = 'zip';
   $config['encrypt_name'] = true;
  
   $this->load->library('upload', $config);
  
   if(!$this->upload->do_upload()) {
    //echo $this->upload->display_errors();
    echo $_FILES['userfile']['type'];
   } else {
    echo 'Uploaded';
   }
  }

}

Any idea why it's doing this? I've tried allowing jpg, png, txt etc but it's still the same.




Theme © iAndrew 2016 - Forum software by © MyBB