Codeigniter:mp4视频不会上传,没有错误 [英] Codeigniter : mp4 video won't upload, no error

查看:422
本文介绍了Codeigniter:mp4视频不会上传,没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个表单来上传视频文件,但我有一个奇怪的错误。

I'm creating a form to upload video file, but I have a strange error.

我的表单是这样:

<div style="color : red;"><?php echo $error;?></div>    
<?php echo form_open_multipart('data_center/ajout_ressource/formulaire_video'); ?>
   //various input text fields...

   <input type="file" name="video">
   <input type="submit" value="Ajouter cette ressource" />
</form>±

我的上传方法是检查表单的其余部分是否正确):

My method to get upload is (it's inside something to check if the rest of the form is ok):

  $dir = './assets/video/';
  $config['upload_path'] = $dir;
  $config['allowed_types'] = 'avi|flv|wmv|mpeg|mp3|mp4';
  $config['max_size']   = '102400';
  $this->load->library('upload',$config);
  if ( ! $this->upload->do_upload('video')){
     $error = array('error' => $this->upload->display_errors());
     $this->load->view('data_center/ajout_video', $error);
  } else {
     redirect('data_center/data_center/','refresh');
  }

关于mime类型,我认为可以:

Concerning mime types, I think it's ok:

'mp4'   =>      'video/mp4',
'wmv'   =>     array('video/wmv', 'video/x-ms-wmv', 'flv-application/octet-stream', 'application/octet-stream'),
'flv'   =>     array('video/flv', 'video/x-flv', 'flv-application/octet-stream', 'application/octet-stream'),
'avi'   =>  'video/x-msvideo',



当我尝试上传一个mp4文件时,虽然我不确定这是一个重定向)的形式,未填充和没有错误消息,即使我评论的行,如果上传失败,不重新加载视图,或者如果其余的形式是不正确的(它不应该尝试上传视频并加载预填充的表单)。


例如,如果我放错了类型的文件,我可以看到错误消息('filetype you正在尝试上传是不允许的例如),或者如果形式是错误的,我可以看到表单的错误。

$
最后,我必须补充说,我修改了php.ini授权这样的大文件,我做了几乎相同的事情与图片(jpg,jpeg,png ...)的表单完美,但也会重定向到一个未填写的形式,如果我尝试上传.mp4文件。


编辑:我刚刚下载了一个flv视频,尝试,它完全正常上传,但它的大小小于8mb(默认配置),一个40mb flv文件有与mp4文件相同的问题,虽然我改变了我的配置在php.ini为100mb

When I try to upload a mp4 file it automatically redirect me (although I'm not sure it's a redirection) to the form, unfilled and no error message, even if I comment the lines in case of upload failure not to load the view again or if the rest of the form is uncorrect (it should not attempt to upload the video and load the form pre-filled).

Whereas for example, if I put the wrong type of file, I can see the error message ('The filetype you are attempting to upload is not allowed' for example), or if the form is wrong I can see the error of the form.

Finally, I must add that I modified php.ini to authorize such big files, and that I did pretty much the same thing with a form for pictures (jpg,jpeg,png...) which works perfectly but also redirect me to an unfilled form if I try to upload a .mp4 file.

I just downloaded an flv video to try, and it uploaded perfectly fine, but its size was less than 8mb (default config), and a 40mb flv file had the same problem as the mp4 file, although I changed my config in php.ini for 100mb

推荐答案

Efectively您必须在PHP ini文件中更改两个参数

Efectively you have to change two parameters in PHP ini file

post_max_size = 100M
upload_max_filesize = 100M

但您可能还想更改apache滥用保护参数(100M)

But you may also want to change the apache abuse protection parameter (100M)

LimitRequestBody 1073741824

另一方面,PHP的每个脚本的时间限制为30秒,所以你的脚本将在30秒的时间内运行。

And by another hand, PHP have a time limit too of 30 sec per script, so your script will die at 30 seconds of running.

你也可以增加

set_time_limit(600);  // 10 minutos execution

这篇关于Codeigniter:mp4视频不会上传,没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆