Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image upload not working in byethost server

I have written code on image upload, but it is not working in byethost server. I created "uploads/products" directory under root location of server, the folder is also writable, but still it is not working. Please help.

I turned on error logging for the application. If I visit "application/logs" directory's log file following error is shown.

ERROR - 2018-03-25 00:47:08 --> 404 Page Not Found: /index

ERROR - 2018-03-25 00:58:24 --> The upload path does not appear to be valid.

Picture of image upload directory in byethost server

enter image description here

Code of my Product Controller.

if(isset($_FILES['productimage']['name'])){
    $filename = $_FILES['productimage']['name']; 
    $config['file_name'] = $filename;
    $config['upload_path'] = realpath(FCPATH.'uploads/products/');
    $config['allowed_types'] = 'jpg|jpeg|png';    
    $config['remove_spaces'] = TRUE;
    $config['encrypt_name'] = TRUE;
    $config['min_width'] = 360;
    $config['min_height'] = 360;
    $config['max_width'] = 360;
    $config['max_height'] = 360;
    $this->upload->initialize($config);
    if($this->upload->do_upload('productimage')){
        $uploadeddata = $this->upload->data();
        $data['image'] = $uploadeddata['file_name'];
    }else{
            $this->session->set_flashdata('error', $this->upload->display_errors());
            $result = array("status"=>false, "message"=>$this->upload->display_errors());
    }

}   
like image 688
Nilesh Sanyal Avatar asked Mar 25 '18 06:03

Nilesh Sanyal


1 Answers

Check upload_tmp_dir permissions (permissions for user, that PHP uses). Native file uploading comes in two steps: uploading to tmp dir and moving to whatever you want.

Also be sure you are trying to upload file that meets upload limit.

like image 111
Victor Perov Avatar answered Sep 28 '22 02:09

Victor Perov