《五》uploadify插件上传文件
来源:互联网 发布:常用医学软件 编辑:程序博客网 时间:2024/05/15 03:06
下载地址:http://www.uploadify.com/wp-content/uploads/files/uploadify.zip
相关配置:http://www.uploadify.com/documentation/
一、 html 上传页面:
<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="__STATIC__/static/uploadify/uploadify.css"/></head><body><input type="file" name="file_upload" id="file_upload" /><img id="img" src=""/></body><script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script><script src="__STATIC__/static/uploadify/jquery.uploadify.min.js"></script><script> $(function() { $("#file_upload").uploadify({ 'swf' : '__STATIC__/static/uploadify/uploadify.swf', 'uploader' : '{:url("/file")}', 'fileObjName' : 'the_files', 'buttonText' : '图片上传', 'onUploadSuccess' : function(file, data, response) { if(response){ var obj=JSON.parse(data); $('#img').attr('src',obj.data); $('#img').attr('width','200px;'); $('#img').attr('height','200px;'); } } }); });</script></html>
二、路由文件:
<?phpuse think\Route;//上传页面Route::rule('map','index/Index/index','GET');//接受上传页面Route::rule('file','api/Upload/index','POST');
三、api/Upload/index 方法:
<?phpnamespace app\api\controller;use think\Controller;use think\Request;class Upload extends Controller{ public function index() { $file=request()->file('the_files'); $info = $file->move('uploads'); if($info){ return [ 'status'=> 1, 'message'=>'success', 'data'=>DS.$info->getPathname() ]; }else{ // 上传失败获取错误信息 echo $file->getError(); } }}
效果:
结束。
阅读全文
0 0
- 《五》uploadify插件上传文件
- JQuery文件上传插件uploadify
- 上传文件插件 Uploadify使用说明
- JQuery文件上传插件Uploadify
- JQuery文件上传插件Uploadify
- 上传文件插件 Uploadify使用说明
- 文件上传利器JQuery上传插件Uploadify
- 文件上传利器JQuery上传插件Uploadify
- uploadify文件上传插件用法介绍
- JSP使用文件上传插件uploadify
- jquery uploadify插件多文件上传
- 上传文件插件uploadify应用简单说明
- jquery uploadify插件多文件上传
- JQ上传文件插件uploadify的手册
- jquery 文件上传插件Uploadify 初探
- jquery uploadify插件多文件上传
- uploadify上传文件插件的的使用
- jquery uploadify插件多文件上传
- 递归法(Recursion)
- 关于AOP无法切入同类调用方法的问题
- Hive常用运算(关系运算)、逻辑运算与数学运算、数值运算、日期函数、条件函数、字符串函数
- struts中action的创建和属性注入
- canvas
- 《五》uploadify插件上传文件
- 掌握 NumPy 常用函数
- Hdu2014 青年歌手大奖赛_评委会打分
- 设计模式之结构型模式
- HTML5 CSS+DIV定位分析(relative,absolute,static,fixed)
- 禁用cookie后session是如何设置的
- OpenDDS开发手册---第二章(开始)5
- 用栈实现队列
- PostgreSQL 创建和删除角色