• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.