簡體   English   中英

在Codeigniter中啟用多張圖片上傳

[英]Enabling multiple image upload in codeigniter

我正在嘗試在Codeigniter中上傳多個圖像。

以下代碼由一個圖像上傳器組成,它僅允許我上傳一個圖像,因為未檢測到其他圖像的詳細信息。

如何啟用它以允許上傳多個圖像?

<?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>

控制者

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)
                    );*/
                }

嘗試這個

<input type="file" multiple name="userfile[]" size="20" />

在控制器方面,您可以按照以下步驟操作

https://stackoverflow.com/a/11539061/4213701

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM