我試圖用笨文件上傳類如下上傳一個MP4視頻文件,問題上傳視頻的MP4的視頻文件,甚至改變MIME類型「MP4」 =>視頻/ MP4,給文件類型爲MP4
後function do_upload_video()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'mp4';
$config['mimes'] = 'mp4';
$config['max_size'] = '1000000';
$this->load->library('upload', $config);
if (! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$data['main_content'] ='admin/elements/add_video';
$this->load->view('includes/template', $data);
}
else
{
$chapter_id=$this->session->userdata('chapter_id');
redirect("/admin/elements/".$chapter_id);
}
}
mime類型在mimes.php 'MP4'=> '視頻/ MP4' 給出 進一步,我也增加文件大小在php.ini post_upload_max size
和upload_max_filesize
到足夠的水平。
但是,當我試圖上傳一個帶有.mp4擴展名的8 MB大小的示例視頻文件時,它顯示錯誤爲「The filetype you are attempting to upload is not allowed
」。
Array ([video] => Array ([name] => daddyshome_paLrcx9H.mp4 [type]=>video/mp4 [tmp_name] => /tmp/php3xrVFp [error] => 0 [size] => 7350845))
得到這對print_r($_FILES)
這可能會幫助你解決你的問題[回答](http://stackoverflow.com/a/19738328/2598994) –