Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. public function bulk_product_upload_file()
  2. {
  3. $location_of_bulk_product_files = LOCATION OF FOLDER;
  4. if ($this->is_post()):
  5. if (is_uploaded_file($_FILES['userfile']['tmp_name'])):
  6. $date_for_file = date("dmyHis");
  7.  
  8. $config['upload_path'] = $location_of_bulk_product_files; //upload directory
  9. $config['allowed_types'] = 'xlsx'; // allowed file types
  10. $config['max_size'] = '100';
  11. $config['overwrite'] = TRUE;
  12. $config['remove_space'] = TRUE;
  13. $config['file_name'] = $date_for_file;
  14. $this->load->library('upload', $config);
  15.  
  16. if($this->upload->do_upload()):
  17. // I have also tried if($this->upload->do_upload('userfile')): that resulted in the same error
  18. echo "file upload success";
  19. else:
  20. echo "file upload failed";
  21. endif;
  22. else:
  23. $this->session->set_flashdata('message_error','Please select a file to upload.');
  24. redirect('main/create_bulk_product');
  25. endif;
  26. else:
  27. $this->session->set_flashdata('message_error','Sorry! Somthing went wrong, please try again.');
  28. redirect('main/create_bulk_product');
  29. endif;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement