我正在使用以下代码在我的 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." }