thinkphp 3.2 多文件上传

浏览:3149 发布日期:2016/12/14 分类:技术分享
核心代码  
<form action="index.php/upload/up" enctype="multipart/form-data" method="post">
        <input type="file" name="remPz[]" >
        <input type="file" name="remPz[]" >
        <input type="file" name="remPz[]" >
        <button id="test" >Click Me!</button>
    </form>

$inf = $upload->upload(array($_FILES['remPz']));
   $config = array(
                'rootPath' => './public/',  //根目录
                'savePath' => $savePath, //保存路径
                'maxSize' => 3292200,//最多上传文件大小
                'allowExts' => explode(',', 'jpg,gif,png,jpeg')//上传文件格式
            );
            $upload = new  \Think\Upload($config);
            $inf = $upload->upload(array($_FILES['remPz']));
            if(!$inf){
                $this->errorJson($upload->getError());
            }else{
                for($i=0;$i<count($inf);$i++){
                    $arr[] = $inf[$i]['savepath'].$inf[$i]['savename'];
                }
                $this->successJson($arr);
            }
最佳答案
评论( 相关
后面还有条评论,点击查看>>