2014-02-18 71 views
0

我試圖用文件上傳類如下上傳一個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 sizeupload_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)

+0

這可能會幫助你解決你的問題[回答](http://stackoverflow.com/a/19738328/2598994) –

回答

0

我從控制器刪除

 $config['mimes'] = 'mp4'; 

,並可以正常工作。

1

設置MIME類型MP4中mime.php

'mp4' => array('video/mp4', 'application/octet-stream'), 
+0

感謝您的意見讓我試試:) –

+0

nope,更改MIME類型,並嘗試上傳但同樣的問題仍然存在。 –

+1

在您的控制器中執行'print_r($ _ FILES);'並檢查類型。 –