doubiaokai4998 2013-12-18 07:23
浏览 68
已采纳

使用带foreach功能的php多个上传文件

Now im working on multiple file uploaded with Codeigniter

any one can help me? because when i'm uploading my file just single file readed.

foreach ($_FILES[$field]['tmp_name'] as $f => $tmp_name) {

        //in here just single file can readed
}

and this is the html code

<form enctype="multipart/form-data"
action="<?php echo site_url('rooms/edit_photo/' . $room_id); ?>" method="post"
onsubmit="return AIM.submit(this, {'onStart' : startCallback, 'onComplete' : completeCallback})">
    <p><label id="upload_photo"
    for="new_photo"><?php echo translate("Upload photo"); ?></label>
    <input name="userfile[]" size="24" type="file" multiple/>&nbsp;&nbsp;
    <button name="update_photo" class="button1" type="submit">
    <span><span><?php echo translate("Upload"); ?></span></span></button>
    </p>
</form>
  • 写回答

1条回答 默认 最新

  • duanjian7343 2013-12-18 07:28
    关注

    You should try to see what's currently in the $_FILES variable. You can do this with print_r($_FILES) or var_dump($_FILES)

    Looks to me that this should be an array, so you're data is probably in this format:

    // for the first picture    
    $_FILES[$field]['tmp_name'][0]
    

    Furthermore: do you know CodeIgniter supplies a uploads library? http://ellislab.com/codeigniter%20/user-guide/libraries/file_uploading.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM