The upload destination folder does not appear to b

2019-09-09 05:34发布

问题:

hi i have this codes from a localhost which works perfectly fine..

function importcsv_attendance() {
        $data['addressbook'] = $this->CSVimportModule_Model->get_addressbook_att();
        $data['error'] = '';    

//initialize image upload error array to empty


    $config['upload_path'] = './uploads/csv/';
    $config['allowed_types'] = 'csv';
    $config['max_size'] = '1000';

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


    // If upload failed, display error
    if (!$this->upload->do_upload()) {
        $data['error'] = $this->upload->display_errors();
        $data['content_view'] = 'CSVimportModule/attendance';
        $this->templates->admin_template($data);

    } else {
        $file_data = $this->upload->data();
        $file_path =  './uploads/csv/'.$file_data['file_name'];

        if ($this->csvimport->get_array($file_path)) {
            $csv_array = $this->csvimport->get_array($file_path);
            foreach ($csv_array as $row) {
                $insert_data = array(
                    'ID_NUM'    =>  $row['ID_NUM'],
                    'DATE'      =>  $row['DATE'],
                    'TIME_IN'   =>  $row['TIME_IN'],
                    'TIME_OUT'  =>  $row['TIME_OUT'],
                    'BREAK_IN'  =>  $row['BREAK_IN'],
                    'BREAK_OUT' =>  $row['BREAK_OUT'],
                    'TOTAL_TIME'=>  $row['TOTAL_TIME'],
                );
                $this->CSVimportModule_Model->insert_csv_att($insert_data);
            }
            $this->session->set_flashdata('success', 'CSV Data Imported Succesfully!');
            redirect(base_url().'CSVimportModule/attendance');
        } else 
            $data['error'] = "Error occured";
            $data['content_view'] = 'CSVimportModule/attendance';
            $this->templates->admin_template($data);
        }

    } 

but when i uploaded the codes to the server, i had this error The upload path does not appear to be valid.. the server is linux. i already checked if there is a folder to be uploaded with. there is an existing folder, but, i still got that error. i also tried to put the whole url on the file path but still, same error.

回答1:

Try with this: if you are using .htaccess then add that folder in .htaccess. Your .htaccess file will look like

RewriteEngine on
Rewritebase /
RewriteCond $1 !^(index\.php|uploads|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

"uploads" is your folder where you are uploading files etc.