《五》uploadify插件上传文件
2017-06-11 16:58
399 查看
下载地址:http://www.uploadify.com/wp-content/uploads/files/uploadify.zip
相关配置:http://www.uploadify.com/documentation/
相关配置: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>
二、路由文件:
<?php use think\Route; //上传页面 Route::rule('map','index/Index/index','GET'); //接受上传页面 Route::rule('file','api/Upload/index','POST');
三、api/Upload/index 方法:
<?php namespace 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(); } } }
效果:
结束。
相关文章推荐
- 用JQuery上传插件Uploadify实现带进度条无刷新多文件上传
- 大文件上传Jquery 插件Uploadify-v2.1.4使用图解
- JQuery文件上传插件Uploadify
- 基于jQuery和Flash的多文件上传插件uploadify在asp.net下session丢失解决方案
- jquery uploadify插件多文件上传
- 用JQuery上传插件Uploadify实现带进度条无刷新多文件上传
- 文件上传插件Uploadify在Struts2中的应用,完整详细实例!
- JSP使用文件上传插件uploadify
- uploadify文件上传插件用法介绍
- 文件上传插件Uploadify在Struts2中的应用,完整详细实例!
- uploadify插件与ssh上传文件到数据库
- Jquery Ajax文件上传插件Uploadify详解(上)
- 上传文件插件 Uploadify使用说明 转
- 使用jquery上传插件uploadify上传多文件(附jQuery Uploadify教程及手册)
- 文件上传插件Uploadify在Struts2中的应用,完整详细实例
- JQuery多文件上传插件Uploadify在ASP.NET中的实现
- 文件上传插件Uploadify在Struts2中的应用,完整详细实例!-克拉
- 使用 jquery 的 上传文件插件 uploadify 3.1 配合 java 来做一个简单的文件上次功能。并且在界面上有radio 的选择内容也要上传
- 上传文件插件uploadify应用简单说明
- 使用jquery的uploadify插件跨域上传文件