【问题标题】:Internal server error during video file upload in php codeigniterphp codeigniter中视频文件上传期间的内部服务器错误
【发布时间】:2017-02-14 18:34:33
【问题描述】:

相同的功能在本地工作,但不在服务器上。

这是我的控制器代码:

public function upload_video() {
    $user_id = $this->session->userdata('userid');
    $config['upload_path'] = './uploads/video/' . $user_id . '/';
    $config['allowed_types'] = 'mp4|flv|wmv';
    $config['encrypt_name'] = true;
    $config['max_size'] = '60240000';

    if (!file_exists($config['upload_path'])) {
        mkdir($config['upload_path']);
    }

    $this->upload->initialize($config);
    if (!$this->upload->do_upload()):

        $error = array('error' => $this->upload->display_errors());
        print_r($error);
    else:

        $data = $this->upload->data();
        $filename = $data['file_name'];
       echo trim($data['file_name'] = $filename);

    endif;

}

【问题讨论】:

  • 您是否在服务器上为上传文件夹设置了适当的权限?
  • 该功能在视频文件小于 10 MB 的服务器上运行良好,仅当我尝试上传大于 10 MB 的文件时才会出现错误。

标签: jquery ajax codeigniter video file-upload


【解决方案1】:

您的if (!$this->upload->do_upload()): 应该是if (!$this->upload->do_upload('user_file')):

其中user_file 是您的文件输入字段的name 属性值。 在这种情况下,您的视图文件应包含以下输入

<input type="file" name="user_file"/>

【讨论】:

  • 可能是你的方向创建问题$test = mkdir($config['upload_path']);var_dump($test)测试它是否返回TRUE
【解决方案2】:

配置您的服务器以接受大文件大小

将您的upload_max_filesizepost_max_size 设置为更大的数字

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-10
    • 1970-01-01
    • 2014-03-01
    • 2018-03-18
    • 2014-02-18
    • 2013-07-14
    • 2012-10-12
    • 1970-01-01
    相关资源
    最近更新 更多