Welcome Guest, Not a member yet? Register   Sign In
File Upload - success but 0 bytes
#1

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();
}
Reply
#2

https://www.codeigniter.com/user_guide/l...ading.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”.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB