时间:2021-07-01 10:21:17 帮助过:11人阅读
模板文件代码:
/Uploadify/uploadify.css" rel="stylesheet" type="text/css" />
控制器代码:
public function uploads(){ $arr = array( "errorcode"=>"1","errormsg"=>"上传成功!"); $model = M('applicant'); if (!empty($_FILES)) { //图片上传设置 $config = array( 'maxSize' => 1000000, 'rootPath' => 'Public', 'savePath' => '/Uploads/', 'saveName' => array('uniqid',''), 'exts' => array('jpg', 'gif', 'png', 'jpeg'), 'autoSub' => false, 'subName' => array('date','Ymd'), ); $upload = new \Think\Upload($config);// 实例化上传类 $info = $upload->upload(); if($info){ $arr['errorcode'] = "0"; } else { $arr["errorcode"] = "1"; $arr["errormsg"] = $upload->getError(); } /* 返回JSON数据 */ $this->ajaxReturn($arr); } }
希望本文所述对大家的php程序设计有所帮助。