Has anyone else had trouble uploading a csv file into Codeigniter? I'm getting a pretty annoying "The filetype you are attempting to upload is not allowed." error, even though I've quite explicitly set the upload type. Here's my code (should be fairly standard stuff):
function doUpload() {
$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'text/plain|text/csv|csv';
$config['max_size'] = '5000';
$config['file_name'] = 'upload' . time();
$this->load->library('upload', $config);
if(!$this->upload->do_upload()) echo $this->upload->display_errors();
else {
$file_info = $this->upload->data();
$csvfilepath = "uploads/" . $file_info['file_name'];
$this->addfromcsv($csvfilepath);
}
}
I tried to cover all the bases in my allowed types - maybe I missed one?
Thanks for any help with this!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…