一次上传两个文件 [英] Upload two files at once
本文介绍了一次上传两个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图同时上传两个文件(两个文件字段)与codeigniters上传类。尽管提供了字段名称codeigniter在第二个字段产生错误。
I am trying to upload two files at once (two file fields) with codeigniters upload class. Despite having provided the field name codeigniter produces errors on the second field.
我这是一个限制codeigniter,php或html或者我只是使用类incorectly? p>
I this a limitation of codeigniter, php or html or am I simply using the class incorectly?
$this->upload->do_upload('video_file')
$this->upload->do_upload('image_file')
在图片字段上生成此项:
Produces this on the image field:
The filetype you are attempting to upload is not allowed.
以下是我的两个函数
function upload_image() {
$thumb_size = 94;
$config['upload_path'] = './assets/uploads/images/';
$config['allowed_types'] = 'jpg|png|gif';
$config['max_size'] = '2048';
$config['file_name'] = 'video_' . rand(999999, 999999999);
$this->load->library('upload', $config);
if (!$this->upload->do_upload('image_file')) {
$error = array('error' => $this->upload->display_errors());
return $error;
} else {
function upload_video() {
$config['upload_path'] = './assets/uploads/videos/';
$config['allowed_types'] = 'flv';
$config['max_size'] = '0';
$config['file_name'] = 'video_' . rand(999999, 999999999);
$this->load->library('upload', $config);
if (!$this->upload->do_upload('video_file')) {
$error = array('error' => $this->upload->display_errors());
return $error;
} else {
推荐答案
class as $ this-> load-> library('upload');
然后使用 $ this-> upload-> initialize $ config);
每次我上传一个新文件。
It worked loading the class as $this->load->library('upload');
then using $this->upload->initialize($config);
each time I upload a new file.
这篇关于一次上传两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文