ローカルで動作しますが、試した 2 台のサーバーで同じエラー メッセージが表示されます。Codeigniter 2.1.3 の使用
private function upload_file(){
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'jpg|png|jpeg|gif|pdf';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
var_dump($_FILES);
if ( ! $this->upload->do_upload()){
$error = array('error' => $this->upload->display_errors());
var_dump($error);
die();
return $error;
} else {
$data = array('upload_data' => $this->upload->data());
var_dump($data);
die();
return $data;
}
}
実行中var_dump($_FILES);
に正しい情報が表示されます
array(1) { ["userfile"]=> array(5) { ["name"]=> string(8) "0002.pdf" ["type"]=> string(14) "aplication/pdf" ["tmp_name"]=> string(27) "C:\Windows\Temp\php9454.tmp" ["error"]=> int(0) ["size"]=> int(29295) } }
var_dump($error)
放つarray(1) { ["error"]=> string(64) " The filetype you are attempting to upload is not allowed. " }
png と jpg の両方でテストされ、これらは素晴らしく機能します。
正しい MIME タイプは構成ファイルにありますconfig/mimes.php
'pdf' => array('application/pdf', 'application/x-download'),
編集:それが何かを意味する場合、ローカルサーバーはMACであり、2つのリモートはWindowsです。