Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Problems with file upload!
#1

(This post was last modified: 06-16-2015, 12:39 PM by Dracula.)

Hi guys,

I'm having some issues with the file upload in CodeIgniter as fallows:


PHP Code:
   public function do_upload($id null)
 
   {

 
       //dump_exit($_FILES['userfile']);

 
       // Temporary upload the image
 
       $config['upload_path'] = $this->slider_path;
 
       $config['allowed_types'] = '*';
 
       $config['overwrite'] = true;
 
       $config['max_size'] = 0;
 
       $config['max_width'] = 0;
 
       $config['max_height'] = 0;
 
       $config['remove_spaces'] = true;

 
       $this->load->library('upload'$config);

 
       if (!is_dir($this->slider_path)) {
 
           mkdir($this->slider_path0755true);
 
       }


 
       if (!$this->upload->do_upload()) {
 
           $this->session->set_flashdata('upload_message'$this->image_lib->display_errors(''''));
 
           
            
// just for testing
 
           $upload_data $this->upload->data();
 
           dump_exit($upload_data);

 
           redirect('admin/slider');
 
       

It doesn't matter what ihave in my controller or view - the code above is from my model.

So, when ai dump the $_FILES['userfile'] on screen i get all the data about the file uploaded. Witch is ok.
But when idump the uploaded data to the screen i get this:


Code:
Dump => array(14) {
 ["file_name"] => string(0) ""
 ["file_type"] => string(0) ""
 ["file_path"] => string(50) "/usr/local/zend/apache2/htdocs/files/images/slider"
 ["full_path"] => string(50) "/usr/local/zend/apache2/htdocs/files/images/slider"
 ["raw_name"] => string(0) ""
 ["orig_name"] => string(0) ""
 ["client_name"] => string(0) ""
 ["file_ext"] => string(0) ""
 ["file_size"] => NULL
 ["is_image"] => bool(false)
 ["image_width"] => NULL
 ["image_height"] => NULL
 ["image_type"] => string(0) ""
 ["image_size_str"] => string(0) ""
}


...absolutley no info about the image uploaded.

P.S. - ignore the $this->slider_path - is the path to images for slider.
P.S. 2 - the image library is loaded in the constructor method.


Edit: Directory permision problems!
[url=//www.pinterest.com/pin/create/extension/][/url]
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro
Reply
#2

Why not use this to display the errors? $this->upload->display_errors();
Reply




Theme © iAndrew 2016 - Forum software by © MyBB