[eluser]thesleepydog[/eluser]
I searched the forums and tried a few fixes but still can't get my upload function to accept a zip file. Error: Filetype not allowed. Other files listed in the config work fine. Here is my code. Thanks in advance for your time!
Controller
Code:
public function upload_files()
{
//check access
$access = $this->_check_auth_admin();
if ($access != 1)
{
show_404();
}
$type = $this->input->post('type');
//config for file upload class
$config['upload_path'] = './partner_assets/' . $type;
$config['allowed_types'] = 'jpg|png|eps|pdf|doc|xls|ppt|txt|ai|psd|zip';
$config['max_size'] = '0';
//load additional libraries
$this->load->helper('form');
$this->load->library('upload', $config);
//set title
$this->data['title'] = "Materials Upload";
//get navigation
$this->data['sections'] = $this->navigator->get_navigator_sections($access);
//set options for form elements
$this->data['form_options'] = array(
'id' => 'upload_form'
);
$this->data['name_options'] = array(
'id' => 'name',
'name' => 'name',
'size' => '46',
'maxlength' => '50'
);
$this->data['description_options'] = array(
'id' => 'description',
'name' => 'description',
'rows' => '3',
'columns' => '25',
'maxlength' => '100'
);
$this->data['type_options'] = array(
'slicks' => 'Slicks',
'logos' => 'Logos',
'manuals' => 'Manuals',
'documents' => 'Documents'
);
$this->data['usage_options'] = array(
'web/screen' => 'Web/Screen',
'print' => 'Print',
);
$this->data['active_options'] = array(
'1' => 'Yes',
'0' => 'No',
);
if ( ! $this->upload->do_upload())
{
$this->data['message'] = $this->upload->display_errors();
//generate view
$this->load->view('templates/header', $this->data);
$this->load->view('templates/sections', $this->data);
$this->load->view('materials/upload_files', $this->data);
$this->load->view('templates/footer');
}
else
{
//set upload data
$file = $this->upload->data();
$material_object = new stdClass;
$material_object->name = $this->input->post('name');
$material_object->description = $this->input->post('description');
$material_object->type = $this->input->post('type');
$material_object->thumbnail = '';
$material_object->file = url_title($file['file_name'], 'underscore', TRUE);
$material_object->usage = $this->input->post('usage');
$material_object->active = $this->input->post('active');
if ( ! $this->materials_model->add_materials_data($material_object))
{
$this->session->set_flashdata($this->upload->display_errors());
redirect('materials/upload_files', 'refresh');
}
else
{
//set messages
$this->session->set_flashdata('message', "You did a great job uploading that file!");
redirect('materials/index', 'refresh');
}
}
}
File
Code:
Array ( [userfile] => Array ( [name] => exx_ptr_logo_pkg.zip [type] => application/zip [tmp_name] => /var/tmp/phpys3tpQ [error] => 0 [size] => 196512 ) )
Mimes.php
Code:
'zip' => array('application/zip', 'application/x-zip', 'application/x-zip-compressed', 'application/octet-stream', 'application/x-compress', 'application/x-compressed', 'multipart/x-zip'),