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.I在do_upload()中也嘗試了同樣的事情,它給出了相同的錯誤。
看到這個帖子: https://stackoverflow.com/questions/968196/how-to-make-codeigniter-file-upload-class-accept-all-extensions它也可能是一個MIME類型不匹配在這裏閱讀更多:https:// stackoverflow。 com/a/34622977/2275490 – Vickel
謝謝維克爾,那是因爲默劇年,不是它已經解決了。 –