• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
codeigniter 3 file upload not working on iis

#1
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
Reply

#2
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).
Reply

#3
(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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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