Welcome Guest, Not a member yet? Register   Sign In
File Upload Path does not appear to be valid
#1

[eluser]Unknown[/eluser]
Hi there, as the title suggests, I'm having some issue with the file upload

Code:
// MAIN EVENT BANNER
    // will ONLY upload a file or change anything if there's been a file submitted
    if(!empty($_FILES['banner']['name']))
    {
     $config['upload_path']      = './uploads/banners/';
     $config['allowed_types']    = 'png'; // only PNG file types are allowed
     $config['max_size']         = '10240';
     $config['max_width']        = '958';
     $config['max_height']       = '298';
     $config['remove_spaces']    = 'true';
     $config['overwrite']        = 'true';

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

     if($this->upload->do_upload('banner'))
     {
      $data['upload_data'] = $this->upload->data();
      $event['banner'] = 'uploads/event/banners/' . $data['upload_data']['file_name'];
     }
     else
     {
       // if the upload fails, do NOT change the banner
       if(is_dir($config['upload_path']))
       {
         echo 'yes, directory exists';
       }
       else
       {
         echo 'no, directory does not exist';
       }

       echo '<br />';

       if(is_writable($config['upload_path']))
       {
         echo 'yes, directory writable';
       }
       else
       {
         echo 'no, directory not writable';
       }
      
       $error = array('error' => $this->upload->display_errors());
     }
    }
    else
    {
      $event['banner'] = 'placeholder.jpg';
    }

My code returns that the directory IS writable, and it DOES exist. But I keep getting caught with an error message telling me the file upload path is invalid.

I have the same code elsewhere (for blog posts) and it works perfectly. So, I'm somewhat confused?
#2

[eluser]TheFuzzy0ne[/eluser]
I'm not sure what's going on there. Everything looks fine to me.

Are you running your Web server on Windows?

I would suggest using is_really_writable() as opposed to is_writeable, and also making your path relative to your application directory by using the APPPATH constant.




Theme © iAndrew 2016 - Forum software by © MyBB