0

Im Trying to Upload a zip file or a jpg file but i keep getting an error

-- The filetype you are attempting to upload is not allowed.

$this->_check();


$this->load->helper('string');

$email=$this->input->post('email');

$orderid=$this->input->post('order');

   $_FILES['filename']['name'];

// $_FILES['filename']['type']; 
// $_FILES['filename']['tmp_name'];
// $_FILES['filename']['size'];
 $xyz=$ext = pathinfo( $_FILES['filename']['name'], PATHINFO_EXTENSION);

        
$config['upload_path'] = './assets/upload/zipfiles/' ;

    $config['allowed_types'] = 'zip';
 $ac=$config['file_name']="final_".$orderid."_".$email."_".random_string('alnum',5).".".$xyz;

  print_r($config);echo "<Br><br><br>"; print_r($_FILES);

       $this->upload->initialize($config);

  if($this->upload->do_upload('filename')){

    $zipname='assets/upload/zipfiles/'.$ac['file_name'];

    echo $zipname;

  }else{        

     echo $this->upload->display_errors();
    }
}

My Arrays Config and filename

Array ( [upload_path] => ./assets/upload/zipfiles/ [allowed_types] => gif|jpg|png [file_name] => final_160716163335-p4IM5Tu_emailaddress.com_R6JLk.jpg ) 

Array ( [filename] => Array ( [name] => a b c.jpg [type] => image/jpeg [tmp_name] => C:\wamp\tmp\phpFAF6.tmp [error] => 0 [size] => 105 ) )
Community
  • 1
  • 1
Reuben Gomes
  • 878
  • 9
  • 16
  • Check http://stackoverflow.com/questions/7495407/uploading-in-codeigniter-the-filetype-you-are-attempting-to-upload-is-not-allo – Saty Jul 19 '16 at 09:54
  • @Saty im using CI 3 iv already checked my system files (CI3 Fixes the bux) also i have 4 functions doing multi file upload its just that im attempting to do single file upload and im getting this error – Reuben Gomes Jul 19 '16 at 09:56
  • check your file type is jpg not zip `[name] => a b c.jpg`. Change `$config['allowed_types'] = 'zip';` to `$config['allowed_types'] = 'gif|jpg|png';` – Saty Jul 19 '16 at 09:59
  • @saty i got the problem i was trying to upload damaged images the images were from when i was trying to work with image download with rename function into zip folder – Reuben Gomes Jul 19 '16 at 10:09
  • @ReubenGomes please check this one http://stackoverflow.com/questions/9815208/codeigniter-the-filetype-you-are-attempting-to-upload-is-not-allowed – Kushal Suthar Jul 19 '16 at 12:26

0 Answers0