模板程序:
<form action="{:U('Index/upload')}" enctype='multipart/form-data' method='post'> <input type="file" name='photo'> <input type="submit" value='提交'> </form>
php程序:
public function upload(){ $upload=new ThinkUpload(); $upload->maxSize=3145728; $upload->exts=array('jpg','gif','png','jpeg','bmp','xlsx','docx','pdf','rar','zip'); $upload->rootPath='./Uploads/'; $upload->savePath=''; if ($upload->upload()) { $this->success('上传成功'); }else{ $this->error($upload->getError()); } }
完成!