【发布时间】:2011-12-10 03:51:44
【问题描述】:
我有一个页面可以插入用户名、ID,并且用户必须能够上传最多 10 张图片。
我遇到的主要问题是使用 codeigniter 上传多个图像时。
有人可以建议我如何传递每个图像的每个路径 单个图像到数组,以便我可以将其传递到数据库。
-
如果用户选择上传的图片少于 10 张,例如 2 张或 5 张 那我怎么能忽略说文件还没有的错误 selected 和 jst 仅传递已上传的图像。
<form method="post" action="uploader/go" enctype="multipart/form-data"> <input name="username" type="text" /><br /> <input name="nid" type="text" /><br /> <input type="file" name="image1" /><br /> <input type="file" name="image2" /><br /> <input type="file" name="image3" /><br /> <input type="file" name="image4" /><br /> <input type="file" name="image5" /><br /> <input type="file" name="image6" /><br /> <input type="file" name="image7" /><br /> <input type="file" name="image8" /><br /> <input type="file" name="image9" /><br /> <input type="file" name="image10" /><br /> <input type="submit" name="go" value="Upload!!!" /> </form>
示例控制器
$image_data=array('image_info' => $this->upload->data('image'));
$image_path=$image_data['image_info']['full_path'];
$data =array(
'id'=>uniqid('id_'),
'nID'=>$this->input->post('nid'),
'username'=>$username,
'image1'=>$image_path
}
我们将不胜感激。
【问题讨论】:
标签: php codeigniter file-upload codeigniter-2