CodeIgniter Forums
codeigniter 3 file upload not working on iis - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: codeigniter 3 file upload not working on iis (/showthread.php?tid=74320)



codeigniter 3 file upload not working on iis - tp45 - 09-10-2019

Hello 
Am running codeigniter 3 on iis  so am trying to upload an image but it is not uploading and it is not giving an error, but when i post text it works
here is my upload code:

PHP Code:
public function post(){

        
  if (empty($this->input->post('post_text')) && empty($_FILES['image']['name'])) {
            
redirect('posts');
        
  }

        
  $config['upload_path'] = './assets/images/postimages';
          $config['allowed_types'] = 'gif|jpg|png|jpeg';
          $config['max_size'] = '2048';

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



          if (!empty($_FILES['image']['name'])) {

              if ($this->upload->do_upload('image')) {
                  $post_image $_FILES['image']['name'];
        
        if ($this->Post_model->addPost($post_image)) {
        
          array('upload_data' => $this->upload->data());
        
          redirect('posts');
        
        }else{
        
          $this->session->set_flashdata('post_errors''Sorry something went wrong, Please try again');
        
          redirect('posts');
        
        }
            }else{
            
//to diagnose i put else  here and put redirect function
              
redirect('posts');
              
//so i try to upload an image it always come to else, if i remove else and submit the form it just go to the url and stops
              
like it go here http://localhost/friendmiiDemo/posts/post and stop
           
}
            

          }else{
              if ($this->Post_model->addPost()) {
    
          redirect('posts');
        
    }else{
    
          $this->session->set_flashdata('post_errors''Sorry something went wrong, Please try again');
    
          redirect('posts');
        
    }
          }



on xampp it works great but on iis does not work
i dont know the problem please help
Thanks in advance


RE: codeigniter 3 file upload not working on iis - jreklund - 09-10-2019

It's usually a file directory security problem, as the IIS user don't have write access to your upload folder.
You can fix it like this:
Right click on upload folder
Properties
Security
Edit
Select "Users (COMPUTER\Users)"
Check "Modify" and "Write"
Ok
Ok

If you don't want all users to have write access, you will need to find what user account IIS runs under (I got no idea).


RE: codeigniter 3 file upload not working on iis - tp45 - 09-10-2019

(09-10-2019, 07:23 AM)jreklund Wrote: It's usually a file directory security problem, as the IIS user don't have write access to your upload folder.
You can fix it like this:
Right click on upload folder
Properties
Security
Edit
Select "Users (COMPUTER\Users)"
Check "Modify" and "Write"
Ok
Ok

If you don't want all users to have write access, you will need to find what user account IIS runs under (I got no idea).
It worked thank you so much.