public function upload(){ import("ORG.Net.UploadFile"); $upload = new UploadFile(); //设置上传文件大小 $upload->maxsize = 3145728; //设置上传文件类型 $upload->allowExts = explode(',',"jpg,gif,jpeg,png"); //设置附近上传目录 $upload->savePath = "./Upload/zpimg/"; //注意 目录为入口文件的相对路径 //设置需要生成缩略图他,仅对图片文件有效 //$upload->thumb = true; //设置引用图片类库包路径 //$upload->imageClassPath = 'ORG.Net.Image'; //设置需要生成缩略图他的文件后缀 //$upload->thumbPrefix ='m_,s_'; //生成2张缩略图 //设置缩略图最大宽度 //$upload->thumbMaxWidth = '400,100'; //设置缩略图最大高度 //$upload->thumbMaxHeight = '400,100'; //设置上传文件规则 $upload->saveRule = uniqid; //删除原图 $upload->thumbRemoveOrigin = true; if(!$upload->upload()){ //捕获上传异常 $this->error($upload->getErrorMsg()); }else{ //取得成功上传文件信息 $info = $upload->getUploadFileInfo(); //$this -> success("上传成功"); } return $info; }
下面是我的一个调用类拿过来分享 这里是两张图片上传:
if($_FILES['photo']['size']>0){ $file_name = $this->upload(); $data['list_photo'] = $file_name[0]['savename']; $data['photo2'] = $file_name[1]['savename']; }
把变量都放到$data 里面了。可以插入或者修改了!!