Вопрос

I have a codeigniter project that I deployed to pagodabox, the problem is that it has a file upload form which is supposed to upload csv files but somehow I get an error saying that the filetype is not allowed. It however worked on my local wamp server.

Any help will be appreciated. here is my code

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Uploadfile extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        //Do your magic here    
        $this->load->library('csvreader');                      
    }

    function upload() {         
        $session_data = $this->session->userdata('logged_in');
        $current_user_name = $session_data['username'];     
        $config = array('upload_path' => 'application/uploads',
                        'max_size' =>   '0',
                        'allowed_types' => 'csv',
                        'file_name' => $current_user_name,
                        'overwrite' => true
                         );
        $this->load->library('upload', $config);

        $upload_field_name = 'csvfile';         

         if ( ! $this->upload->do_upload($upload_field_name)){
            $error = array('error' => $this->upload->display_errors());             
            $this->load->view('upload_error', $error);
            var_dump('$upload_field_name');
         }
         else {

            $csvfile = array('csvfile' => $this->upload->data($upload_field_name));             
            $csvdata = $this->csvreader->parse_file($csvfile['csvfile']['full_path']);  
            $data['jsondata'] = json_encode($csvdata);                                              
            $this->load->view('dashboard', $data);

         }

    }

} ?>

Это было полезно?

Решение

Have you specified in your Boxfile that this folder is writable:

web1
...
  shared_writable_dirs: 
    - /application/uploads/  
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top