![]() |
File Upload - success but 0 bytes - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: File Upload - success but 0 bytes (/showthread.php?tid=67346) |
File Upload - success but 0 bytes - gerrylarry - 02-13-2017 I am uploading a text file and there doesn't appear to be any error message but afterwards, the uploaded file is empty - 0 bytes. Here is the code I'm using. Any ideas. I've got other features that upload files successfully and I've cloned that here. $data['resultmsg'] = ""; $this->load->helper('form'); $config['upload_path'] = 'application/import/'; $config['allowed_types'] = 'txt'; $config['overwrite'] = true; $this->load->library('upload', $config); $this->upload->initialize($config); $this->upload->set_allowed_types('*'); $data['upload_data'] = ''; if (!$this->upload->do_upload('userfile')) { $data['resultmsg'] = $this->upload->display_errors(); } else { $data['resultmsg'] = "Upload success!"; $data['upload_data'] = $this->upload->data(); } RE: File Upload - success but 0 bytes - andersonunsonst - 02-13-2017 https://www.codeigniter.com/user_guide/libraries/file_uploading.html By default the upload routine expects the file to come from a form field called userfile, and the form must be of type “multipart”. |