[英]Enabling multiple image upload in codeigniter
I am trying to upload multiple images in codeigniter. 我正在尝试在Codeigniter中上传多个图像。
The following code consists of a image uploader, it only allow me to upload one image as the details of other images are not detected. 以下代码由一个图像上传器组成,它仅允许我上传一个图像,因为未检测到其他图像的详细信息。
How can I go about enabling it to allow upload of multiple images? 如何启用它以允许上传多个图像?
<?php echo form_open_multipart('backendProduct/product_image_upload?item_id='.$item_id);?>
<div class="input-group">
<?php echo "item id is: "; echo $item_id;?>
<?php echo form_upload(array('name'=>'userfile', 'class'=>'form-control'));?>
<span class="input-group-btn">
<button class="btn btn-primary" name="submit" type="submit"><i class="icon-upload"></i></button>
</span>
</div>
</form>
controller 控制者
foreach($post as $key=> $value)
{
//retrieve the $key that start with 'images_files'
if (0 === strpos($key, 'images_files'))
{
log_message('debug', '['.__CLASS__.']['.__FUNCTION__.']['.$key.']['.print_r($value,TRUE).']');
//$images_files = $value;
$images_files = $value[1];
echo $images_files;
}
elseif(0 === strpos($key, 'images_alt'))
{
log_message('debug', '['.__CLASS__.']['.__FUNCTION__.']['.$key.']['.print_r($value,TRUE).']');
$images_alt = $value;
}
elseif(0 === strpos($key, 'images_caption'))
{
log_message('debug', '['.__CLASS__.']['.__FUNCTION__.']['.$key.']['.print_r($value,TRUE).']');
$images_caption = $value;
/*array_push($images,
array(
,,$value)
);*/
}
try this 尝试这个
<input type="file" multiple name="userfile[]" size="20" />
and on your controller side, you can follow this 在控制器方面,您可以按照以下步骤操作
https://stackoverflow.com/a/11539061/4213701 https://stackoverflow.com/a/11539061/4213701
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.