thinkphp和uploadfiy
2016-05-12 15:24
525 查看
上传页面 用的是bootstrap <div class="col-sm-6"> <div style="width: 200px; height: 110px; float: left;"> <input type="hidden" name="photo" value="" id="data_photo" /> <input id="photo_file" name="photo_file" type="file" multiple="true" value="" /> </div> <div style="height: 110px; float: left;"> <img id="upload_img" src="" onerror="this.src='__PUBLIC__/Admin/img/no_img.jpg'" style="height: 100px" /> </div> </div>
$(function(){ $('#photo_file').uploadify({ 'swf' :'__PUBLIC__/admin/swf/uploadify.swf', //swf的相对路径 'uploader': '{:U("Upload/upload")}', //后台处理 'buttonText': '上传头像', //按钮 'height': 35, //高度 'fileTypeExts': '*.gif;*.jpg;*.png', //上传类型 'queueSizeLimit': 1, 'onUploadSuccess': function(file, data, response) { $("#upload_img").attr('src', '__PUBLIC__/Uploads/adminimg/' + data); //预览效果 $("#data_photo").val(data); } }); }); 详细的 http://www.cnblogs.com/mofish/archive/2012/11/30/2796698.html 这个非常不错
public function upload(){ $upload = new \Think\Upload();// ʵ�����ϴ��� $upload->maxSize = 3145728 ;// ���ø����ϴ���С $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// ���ø����ϴ����� $upload->rootPath = './Public/Uploads/adminimg/'; // ���ø����ϴ���Ŀ¼ $upload->savePath = ''; // ���ø����ϴ����ӣ�Ŀ¼ // �ϴ��ļ� $info = $upload->upload(); if(!$info) {// �ϴ�������ʾ������Ϣ $this->error($upload->getError()); }else{// �ϴ��ɹ� foreach($info as $file){ echo $file['savepath'].$file['savename']; } } }
相关文章推荐
- php 内置的 webserver 研究。
- PHP中非常有用的函数
- lamp访问的时候index.php时直接下载了该文件
- php 系列
- Ubuntu配置tftp服务器
- Please check your autoconf installation and the $PHP_AUTOCONF environment variable.
- PHP数组函数基础知识
- thinkphp框架下404页面设置
- php 解决json_encode中文UNICODE转码问题
- PHP 分页
- php关于static关键字
- PHP 正则表达式
- Mac - 使用php环境
- PHP扩展开发--02.包裹第三方的扩展
- PHP扩展开发--01.编写一个helloWorld扩展
- php 正则中的"i,m,s,x,e"分别表示什么
- PHP扩展--opcache安装及配置
- PHP扩展--taint检测隐藏漏洞
- PHP扩展--vld查看opcode代码
- PHP扩展--XHProf优化PHP程序