Welcome Guest, Not a member yet? Register   Sign In
File Not Move To Destination Folder
#1

I am having a problem uploading an image file to a destination folder in my CodeIgniter application and it is not working at all. I have referred so many articles and downloaded some working one but they wouldn't work once in my application and I am thinking it might be my .htaccess file or what. When I remove the upload $this->upload->do_upload('fileupload') path of the doUpload function and remove the if conditional statement, record got inserted in the database successfully even with extracting the name of the uploaded file and inserting it in the database table but once I put the $this->upload->do_upload('fileupload'), it will not work, meaning the Codeigniter do_upload() is not moving the file.

Please check my code doUpload() function :


,,,

Code:
public function doUpload()
        {              
                $config['upload_path'] = './Adverts/';  //Adverts is a folder created in the directory where i have codeigniter application folder
                $config['allowed_types'] = 'gif|jpg|png';
                $config['max_size'] = '100048';
                $config['file_name'] = $_FILES['fileupload']['name'];

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

                if ($this->upload->do_upload('fileupload'))
                {
                    $data2 = array(
                              'AdvertCode'=>$this->input->post('advertcode'),
                              'CustomersName'=>$this->input->post('customersname'),
                              'AdvertSubject'=>$this->input->post('advertsubject'),
                              'AdvertMessage'=>$this->input->post('editor1'),
                              'AdvertPhotoName'=>$config['file_name'],
                              'Addedby'=>$this->input->post('addedby')
                            );

                        $this->db->insert('mytable', $data2);

            $this->session->set_flashdata('Added Successfully','Record  successfully added');
                            $this->loadRecord();                    
                }
                else
                {  
                        echo 'Error uploading file';                                                                                                                          
                }
        }

,,,

Below is my .htaccess file

,,,

Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]


,,,

Please help me on this as it is killing me big time. Attached to this post is my folder structure.

I appreciate all efforts in advance.

Regards,

Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
File Not Move To Destination Folder - by olammieconcept - 12-17-2019, 06:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB