1

我正在使用以下代码在我的 codeigniter 项目中上传视频。

这是我的视图代码

<?php echo $error;?>
<?php echo form_open_multipart('upload/do_upload');?>
    <input type="file" name="userfile" size="20" />
    <input type="submit" value="upload" />
</form>

这是控制器

class Upload extends CI_Controller {
    public function __construct()
    {
        parent::__construct();
        $this->load->helper(array('form', 'url'));
    }
    public function do_upload()
    {
        $config['upload_path']          = './uploads/';
        $config['allowed_types']        = 'gif|jpg|png|mp4';
        $config['max_size']             = 100000;
        $config['max_width']            = 1024;
        $config['max_height']           = 768;
    
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload('userfile'))
        {
            $error = array('error' => $this->upload->display_errors());
            var_dump($error);
        }
        else
            $data = array('upload_data' => $this->upload->data());
    }
}

此代码通过 xampp 工作正常。但我在实时服务器/cpanl 中遇到错误。当我每次尝试上传视频时都会显示以下错误,

array(1) { 
    ["error"]=> string(43) 
    "You did not select a file to upload." }
4

1 回答 1

0

看起来上传或功能可能在 php.ini 中被禁用,尝试使用 error_reporting(E_ALL); 运行您的代码;看看是否发生了一些错误,除了你没有选择要上传的文件。错误

于 2020-12-07T07:34:32.513 回答