【问题标题】:Why I'm getting this error: The filetype you are attempting to upload is not allowed为什么我收到此错误:不允许您尝试上传的文件类型
【发布时间】:2017-10-12 19:41:17
【问题描述】:
public function addAppdetails()
    {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('appname', 'App Name', 'required');
        $this->form_validation->set_rules('platform', 'Platform', 'required');
        //$this->form_validation->set_rules('category','App Category','required');
        $this->form_validation->set_rules('description', 'App Description', 'required');
        //$this->form_validation->set_rules('app_pic','App Pic','required');
        //$this->form_validation->set_rules('file','App File','required');
        if ($this->form_validation->run()) {
            $appname = $this->input->post('appname');
            $platform = $this->input->post('platform');
            $category1 = $this->input->post('category');
            $descripton = $this->input->post('description');
            $category = implode(",", $category1);
            $data = array('name' => $appname, 'platform' => $platform, 'description' => $descripton, 'category' => $category);
            $this->appImageupload();
            die;
            $this->Dev_model->addApp($data);


        } else {
            $data['dataArray'] = $this->sessionStart();
            $category = $this->input->post('category');
            print_r($category);
            $this->load->view('dev/addApp', $data);
        }
    }

public function appImageupload()
{
    $config['upload_path']          = './uploads/appImages';
    $config['allowed_types']        = 'exe';
    $config['file_type']            = 'exe';
    $config['max_size']             = 1000000000;


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

    if ( ! $this->upload->appImageUpload('app_pic'))
    {
        $error = array('error' => $this->upload->display_errors());
        print_r($error);

    }
    else
    {
        $data = array('upload_data' => $this->upload->data());
        return $data;

    }
}

函数 appImageupoad 用于上传 '.exe' 文件。因此,每当我尝试上传可执行文件时,都会出现错误。但是,如果我将 $config['allowed-type] 更改为 .jpg 或任何图像文件扩展名,则会上传。

P.S.我也在 do_upload() 中尝试过同样的事情,它给出了同样的错误。

【问题讨论】:

标签: php codeigniter codeigniter-2 codeigniter-3


【解决方案1】:

你也可以去掉这几行代码

$config['file_type'] = 'exe'; $config['max_size'] = 1000000000;

您已经指定了允许的类型allowed_types 试一试,如果有效,那么您也可以应用其他验证

【讨论】:

  • 感谢您的回答 :) 实际上,这是因为 mime.php。我必须为 exe 添加 mime 类型
猜你喜欢
  • 1970-01-01
  • 2011-06-08
  • 1970-01-01
  • 2017-08-18
  • 2012-04-06
  • 2019-05-20
  • 2012-04-22
  • 2011-11-21
  • 2014-12-30
相关资源
最近更新 更多