localhost で Codeigniter を使用して、uploads フォルダーにファイルを完全にアップロードできます。ただし、サーバーにアップロードしようとすると、このエラーが発生します。さまざまな種類のファイルを試しました。txt、.doc .xls .jpg など、これらはすべて localhost で問題ありません。私はMIMEファイルを調べました.image/jpegは、必要な他のすべてのファイルタイプ(「doc」=>「application/msword」など....)とともにjpeg用です。フォルダーのアクセス許可も確認しましたが、問題ありませんが、エラーのためにそこまで到達していないことは明らかです。
ファイルのアップロードが許可されない理由を誰か知っていますか。
string(57) "The filetype you are attempting to upload is not allowed." array(2)
{ ["testfile"]=> array(5)
{ ["name"]=> string(7) "123.jpg" ["type"]=> string(10) "image/jpeg"
["tmp_name"]=> string(14) "/tmp/phpVYtNNs" ["error"]=> int(0) ["size"]=> int(20921) }
["quotefile"]=> array(5)
{ ["name"]=> string(7) "123.jpg" ["type"]=> string(10) "image/jpeg"
["tmp_name"]=> string(14) "/tmp/phpIsvQ7x" ["error"]=> int(0) ["size"]=> int(20921) } }
コントローラ:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|txt|pdf|xls|csv|doc';
$config['max_size'] = '1000000';
$config['max_width'] = '100024';
$config['max_height'] = '76008';
$this->load->library('upload', $config);
モデル:
if ( ! $this->upload->do_upload('testfile'))
{
var_dump($this->upload->display_errors('', ''));
var_dump($_FILES);
//$error = array('error' => $this->upload->display_errors());
//echo '<pre>'; print_r($error); echo '</pre>';
//$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data('testfile'));
$this->load->view('upload_success', $data);
}
$upload_data = $this->upload->data('testfile');
if ( ! $this->upload->do_upload('quotefile'))
{
$error = array('error' => $this->upload->display_errors());
echo '<pre>'; print_r($error); echo '</pre>';
//$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data('quotefile'));
$this->load->view('upload_success', $data);
}