CodeIgniter - 使用一个输入上传多个文件 [英] CodeIgniter - uploading multiple files with one input

查看:87
本文介绍了CodeIgniter - 使用一个输入上传多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要从一个输入一次上传多个文件

< input type =filename =form-image []id =form-imagemultiple =true/>

其本身没有 CodeIgniter 的工作正常。在我试图做同样的事情与CodeIgniters文件助手;我收到错误( is_uploaded_file()期望参数1为字符串,给定数组 ) ,这表示我做错了,或者CodeIgniter只是不支持多个文件?

我的错误代码到目前为止: p>

My faulty code so far:

//Iterate through each file uploaded
for ($i = 0; isset($_FILES['form-image']['name'][$i]); $i++) {

   //Fix the settings
   $config['upload_path'] = "./static/vimmel/";
   $config['file_name'] = time() . rand(1,988);
   $config['allowed_types'] = 'gif|jpg|png';
   $config['max_size']  = '1024';
   $config['max_width']  = '1024';
   $config['max_height']  = '768';
   $this->load->library('upload', $config);

   //Do the upload
   $this->upload->do_upload("form-image")
}

请注意,我已经编辑了所有错误处理等。另请注意,我不使用 is_uploaded_file()函数。

欣赏所有帮助和建议。感谢。

Appreciating all help and suggestions. Thanks.

推荐答案

CodeIgniter不支持多个文件。在foreach中使用do_upload()与在外部使用do_upload()没有什么不同。

CodeIgniter doesn't support multiple files. Using the do_upload() in a foreach won't be different than using it outside.

无需CodeIgniter的帮助,你需要处理它。下面是一个示例 https:// github。 com / woxxy / FoOlSlide / blob / master / application / controllers / admin / series.php#L331-370

You will need to deal with it without the help of CodeIgniter. Here's an example https://github.com/woxxy/FoOlSlide/blob/master/application/controllers/admin/series.php#L331-370

这篇关于CodeIgniter - 使用一个输入上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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