thinkphp 上传多张图片

tp3.23 没有找到同时上传多张图片

手册有讲过:http://www.kancloud.cn/manual/thinkphp/1876

其实可以通过,多张图片多次上传来到达效果

hmlt:

<form name="form1" action="/index.php/api/user/uploadimage" method="post" enctype="multipart/form-data">
   <!-- <input type="file" name="photo[]" />-->
    <input type="file" name="photo[]"  multiple="multiple"/>
  <input type="submit" />
</form>

php:

 public function uploadimage(){
        $data=$this->requestdata();
        echo "<pre>";
        print_r($_FILES['photo']);
        print_r($_FILES);

        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     113145728 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->savePath  =      'head_pic/'; // 设置附件上传目录

        $info=array();
        foreach ($_FILES['photo']['name'] as $key=>$value){
            $file1=array();
            $file1["photo"]['name']=$value;
            $file1["photo"]['type']=$_FILES['photo']["type"][$key];
            $file1["photo"]['tmp_name']=$_FILES['photo']["tmp_name"][$key];
            $file1["photo"]['error']=$_FILES['photo']["error"][$key];
            $file1["photo"]['size']=$_FILES['photo']["size"][$key];
            $info   =   $upload->upload();
        }
        print_r($info);
        //print_r($file1);

测试过,可以的

 

 

  

posted @ 2017-03-30 13:39  小小强学习网  阅读(5659)  评论(0编辑  收藏  举报