0

For some reason this block of code works on my local machine but when I upload it to my GoDaddy server it doesn't work, it tells me "The filetype you are attempting to upload is not allowed.". This only happens when I try to upload csv and xlsx files, png and jpgs work no problem.

    $filename = "classlist_".date("YmdHis").".csv";
    $config['upload_path'] = APPPATH. '../uploads/';
    $config['allowed_types'] = 'xlsx|xls|jpg|png|csv';
    $config['max_size'] = '1000';
    $config['max_width']  = '1024';
    $config['max_height']  = '768';

    $this->load->library('upload', $config);

    if (!$this->upload->do_upload())
    {
        print_r($this->upload);

        echo "error<br/>".$this->upload->display_errors();
        exit;
    }
    else
    {
        exit;
Cœur
  • 37,241
  • 25
  • 195
  • 267
Mikerizzo
  • 587
  • 1
  • 4
  • 22

1 Answers1

0

This is a problem of server configuration for that specific filetype. That means that the filetype the server gives you for xlsx is not found in the $mimes variable in mimes.php file. The file mimes.php is found in application/config/mimes.php. Just print the $_FILES variable and add that mime you see there in $mimes variable.

Another method would be to force those mimes in .htaccess file:

AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/excel xls
AddType text/x-comma-separated-values csv
machineaddict
  • 3,216
  • 8
  • 37
  • 61