-1

i would like to upload 2 files to different path but at the first path it's work properly but when it use next path its error with "The filetype you are attempting to upload is not allowed."

Model

    $this->load->model('blogmaintain_helper');
    $data['cover_path'] = $this->blogmaintain_helper->upload_cover();
    $data['file_path'] = $this->blogmaintain_helper->upload_file();

Controller

    function upload_cover(){
        $config_cover['upload_path'] = 'ftp://[server_path]/public_html/img/blog/';
        $config_cover['allowed_types'] = 'gif|jpg|png|tif';
        get_instance()->load->library('upload', $config_cover);
        if($this->upload->do_upload('myFile'))
        {
            echo "Cover upload success";
            return true;
        }
        else
        {
            echo $this->upload->display_errors();
        }
    }
    function upload_file(){

        $config_file['upload_path'] = 'ftp://[server_path]/public_html/document/blog/';
        //$config['upload_path'] = 'document/blog/';
        $config_file['allowed_types'] = 'doc|docx|pdf|txt|xls|xlsx|ppt|pptx';
        get_instance()->load->library('upload', $config_file);
        if($this->upload->do_upload('myDoc'))
        {
            echo "File upload success";
        }
        else
        {
            echo $this->upload->display_errors();
        }
    }

i can upload myFile to img/blog but when it perform 'upload_file' it's error with "The filetype you are attempting to upload is not allowed."

PS* myDoc is "test.txt" and myFile is "pic.jpg"

user2777917
  • 25
  • 1
  • 1
  • 3

2 Answers2

0

Check your mimes.php, txt and all other mime types must be defined there for Codeigniter to recognize and allow them.

If they are not there add them.

Sam Pettersson
  • 3,049
  • 6
  • 23
  • 37
0

This question has been answered a number of times before. It's due to the mime. Here you can see the other questions: 1,2,3.

Community
  • 1
  • 1
Alex
  • 4,674
  • 5
  • 38
  • 59