Home >php教程 >php手册 >使用ThinkPHP+Uploadify实现图片上传功能

使用ThinkPHP+Uploadify实现图片上传功能

WBOY
WBOYOriginal
2016-06-06 20:20:591281browse

这篇文章主要介绍了使用ThinkPHP+Uploadify实现图片上传功能,需要的朋友可以参考下

首先,将下载的Uploadify压缩包解压放到公共文件夹内。实现代码如下:

前台html部分:

上传



action执行代码部分:

public function uploadify() { $ph=M('Upload'); import('ORG.Net.UploadFile'); $upload = new UploadFile();// 实例化上传类 $upload->maxSize = 93145728 ;// 设置附件上传大小 $upload->saveRule =rand(1,9999); $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg','flv','avi','mov');// 设置附件上传类型 $upload->savePath = './Uploads/';// 设置附件上传目录 if(!$upload->upload()) {// 上传错误提示错误信息 $this->error($upload->getErrorMsg()); }else{// 上传成功 获取上传文件信息 $info = $upload->getUploadFileInfo(); } for($i=0;$iadd($data); } /*if($rs) { $this->success("成功"); }else { $this->error("失败"); }*/ }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn