uploadify3.2.1版插件在ASP.NET中的使用
0.先去官网下载插件 下载uploadify3.2.1插件
解压后只需要一下文件:
(2) uploadify.css
(3) uploadify.swf
但是运用到网站后需要应用jquery 1.4以上版本
1.ASP.NET Web Form
简单配置.ASPX文件
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title></title>
- <link type="text/css" rel="stylesheet" href="Content/uploadify/uploadify.css" />
- <script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>
- <script type="text/javascript" src="Content/uploadify/jquery.uploadify.min.js"></script>
- </head>
- <body>
- <input id="file_upload" name="file_upload" type="file" multiple="multiple"/>
- <script type="text/javascript">
- $(document).ready(function () {
- $("#file_upload").uploadify({
- 'swf': 'Content/uploadify/uploadify.swf',
- 'auto': true,
- 'multi': true,
- 'uploader': 'UploadHandler.ashx',//指定一般处理程序 执行上传后的文件处理
- });
- });
- </script>
- </body>
- </html>
创建一般处理程序 重新 ProcessRequest
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- context.Response.Charset="UTF-8";
- HttpPostedFile file=context.Request.Files["Filedata"];
- //这个Filedata 是uploadify fileObjName项的默认值
- string path = HttpContext.Current.Server.MapPath("~/LoadFiles") + "\\";
- if (file != null)
- {
- file.SaveAs(path+file.FileName);
- }
- }
2.ASP.NET MVC3
配置View
- <link type="text/css" rel="stylesheet" href=@Url.Content("~/Content/uploadify/uploadify.css") />
- <script type="text/javascript" src=@Url.Content("~/Scripts/jquery-1.7.1.min.js")></script>
- //我试了很多次,一定要引用Url.Content辅助方法才行
- <script type="text/javascript" src=@Url.Content("~/Content/uploadify/jquery.uploadify.min.js")></script>
- <script type="text/javascript">
- $(function () {
- $("#file_upload").uploadify({
- 'swf': '@Url.Content("~/Content/uploadify/uploadify.swf")',
- 'auto': true,
- 'multi': true,
- 'uploader': 'Person/Upload'
- });
- });
- </script>
- <input id="file_upload" name="file_upload" type="file" multiple="multiple"/>
编写Action 只要捕获到Filedata接算是成功了
- [HttpPost]
- public ActionResult Upload(HttpPostedFileBase Filedata)
- //Filedata不能改名 因为它是uploadify fileObjName项的默认值 除非修改 fileObjName项的默认值
- //不然会报错
- {
- if (Filedata != null)
- {
- //do something.
- }
- return View();
- }
3.ASP.net MVC4
配置View
- <link type="text/css" rel="stylesheet" href=@Url.Content("~/Content/uploadify/uploadify.css") />
- <script type="text/javascript" src=@Url.Content("~/Scripts/jquery-1.7.1.min.js")></script>
- <script type="text/javascript" src=@Url.Content("~/Content/uploadify/jquery.uploadify.min.js")></script>
- <script type="text/javascript">
- $(function () {
- $("#file_upload").uploadify({
- 'swf': '@Url.Content("~/Content/uploadify/uploadify.swf")',
- 'auto': true,
- 'multi': true,
- <span style="color:#FF0000">'uploader': '@Url.Action("Upload","Person")',</span>
- 'folder': 'UpLoadFiles'
- });
- });
- </script>
- <input id="file_upload" name="file_upload" type="file" multiple="multiple"/>
- <span style="font-size:18px; color:#3366FF">:其实和MVC3差不多,只是有一个地方不明白,在MVC4中</span><span style="color:#3366FF">
- 'uploader': '@Url.Action("Upload","Person")' 写成
- </span><pre name="code" class="html"><span style="color:#3366FF"> 'uploader': 'Person/Upload' 会报错。。。。
- </span></pre>
编写Action 和MVC3 一样
- [HttpPost]
- public ActionResult Upload(HttpPostedFileBase Filedata)
- {
- if (Filedata != null)
- {
- //do something
- }
- return View();
- }
以上只是uploadify插件的简单运用,其还有更多的功能需要慢慢学习
uploadify 3.2.1 参数项:
- <span style="font-size:14px">// Required Settings
- id : $this.attr('id'), // The ID of the DOM object
- swf : 'uploadify.swf', // The path to the uploadify SWF file
- uploader : 'uploadify.php', // The path to the server-side upload script
- // Options
- auto : true, // Automatically upload files when added to the queue
- buttonClass : '', // A class name to add to the browse button DOM object
- buttonCursor : 'hand', // The cursor to use with the browse button
- buttonImage : null, // (String or null) The path to an image to use for the Flash browse button if not using CSS to style the button
- buttonText : 'SELECT FILES', // The text to use for the browse button
- checkExisting : false, // The path to a server-side script that checks for existing files on the server
- debug : false, // Turn on swfUpload debugging mode
- fileObjName : 'Filedata', // The name of the file object to use in your server-side script
- fileSizeLimit : 0, // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
- fileTypeDesc : 'All Files', // The description for file types in the browse dialog
- fileTypeExts : '*.*', // Allowed extensions in the browse dialog (server-side validation should also be used)
- height : 30, // The height of the browse button
- itemTemplate : false, // The template for the file item in the queue
- method : 'post', // The method to use when sending files to the server-side upload script
- multi : true, // Allow multiple file selection in the browse dialog
- formData : {}, // An object with additional data to send to the server-side upload script with every file upload
- preventCaching : true, // Adds a random value to the Flash URL to prevent caching of it (conflicts with existing parameters)
- progressData : 'percentage', // ('percentage' or 'speed') Data to show in the queue item during a file upload
- queueID : false, // The ID of the DOM object to use as a file queue (without the #)
- queueSizeLimit : 999, // The maximum number of files that can be in the queue at one time
- removeCompleted : true, // Remove queue items from the queue when they are done uploading
- removeTimeout : 3, // The delay in seconds before removing a queue item if removeCompleted is set to true
- requeueErrors : false, // Keep errored files in the queue and keep trying to upload them
- successTimeout : 30, // The number of seconds to wait for Flash to detect the server's response after the file has finished uploading
- uploadLimit : 0, // The maximum number of files you can upload
- width : 120, // The width of the browse button</span>
:在3.2.1版本中和以前不一样不要乱用像script、cancelImg这样的参数项,是没有用的,反而会把自己弄糊涂
uploadify3.2.1版插件在ASP.NET中的使用的更多相关文章
- [转]仿World Wind构造自己的C#版插件框架——WW插件机制精简改造
很久没自己写东西啦,早该好好总结一下啦!一个大师说过“一个问题不应该被解决两次!”,除了一个好脑筋,再就是要坚持总结. 最近需要搞个系统的插件式框架,我参照World Wind的插件方式构建了个插件框 ...
- 关于Asp.Net中的编程实现下载
经常在论坛看见有人求Asp.Net中编程实现下载的代码,有些还希望能断点续传什么的.其实问题的关键在于权限.B/S和C/S不仅仅是外观上的区别而已. 下载,顾名思义是客户端要下,所以载.你硬塞給人家那 ...
- ASP.NET中后台数据和前台控件的绑定
关于ASP.NET中后台数据库和前台的数据控件的绑定问题 最近一直在学习个知识点,自己创建了SQL Server数据库表,想在ASP.NET中连接数据库,并把数据库中的数据显示在前台,注意,这里的数据 ...
- 在 ASP.NET 中创建数据访问和业务逻辑层(转)
.NET Framework 4 当在 ASP.NET 中处理数据时,可从使用通用软件模式中受益.其中一种模式是将数据访问代码与控制数据访问或提供其他业务规则的业务逻辑代码分开.在此模式中,这两个层均 ...
- ASP.NET中UEditor使用
ASP.NET中UEditor使用 0.ueditor简介 UEditor是由百度WEB前端研发部开发的所见即所得的开源富文本编辑器,具有轻量.可定制.用户体验优秀等特点.开源基于BSD协议,所有源代 ...
- ASP.NET 中的 authentication(验证)与authorization(授权)
这两个东西很绕口,也绕脑袋. 一般来说,了解authentication(验证)的用法即可,用于自定义的用户验证. authorization(授权)主要通过计算机信息来控制. “*”:所有用户: “ ...
- ASP.NET中数据棒图,饼图,柱状图的实现
Web中绘制图形的方法大致有: 1. VML方式:功能强大,但是非常麻烦. 推荐:http://www.elook.net.cn/vml/ 2.使用控件:Dandus, Aspose.chart,Co ...
- 也谈Asp.net 中的身份验证
钱李峰 的这篇博文<Asp.net中的认证与授权>已对Asp.net 中的身份验证进行了不错实践.而我这篇博文,是从初学者的角度补充了一些基础的概念,以便能有个清晰的认识. 一.配置安全身 ...
- 【译】在ASP.NET中创建PDF-iTextSharp起步
原文 [译]在ASP.NET中创建PDF-iTextSharp起步 .Net framework 中自身并不包含可以和pdf打交道的方法.所以,当你需要你的ASP.Net Web应用程序中包含创建或与 ...
随机推荐
- Result(ActionResult、JsonResult、JavaScriptResult等)
一丶ActionResult 应用于Action方法前面的类型,它是Action的返回值,代表Action的执行结果. public ActionResult Index() { return Vie ...
- ProgressDialog的样式
ProgressDialog的样式有两种,一种是圆形不明确状态,一种是水平进度条状态 第一种方式:圆形进度条 final ProgressDialog dialog = new ProgressDia ...
- 关闭的连接: next
1.最近做了一个项目,扫描读取了第三方数据库的数据,结果本来在公司测试没有问题的程序在客户那边一直报如下错误: java.sql.SQLException: 关闭的连接: next 代码如下: //第 ...
- 51nod 1050 循环数组最大子段和【动态规划】
N个整数组成的循环序列a[1],a[2],a[3],-,a[n],求该序列如a[i]+a[i+1]+-+a[j]的连续的子段和的最大值(循环序列是指n个数围成一个圈,因此需要考虑a[n-1],a[n] ...
- LINUX-JPS工具
JPS工具 jps(Java Virtual Machine Process Status Tool)是JDK 1.5提供的一个显示当前所有java进程pid的命令,简单实用,非常适合在linux/u ...
- Trie树 hihocoder 1014
Trie树 hihocoder 1014 传送门 字典树的基本应用 #include<queue> #include<cmath> #include<cstdio> ...
- 通过混合编程分析的方法和机器学习预测Web应用程序的漏洞
通过混合编程分析的方法和机器学习预测Web应用程序的漏洞 由于时间和资源的限制,web软件工程师需要支持识别出有漏洞的代码.一个实用的方法用来预测漏洞代码可以提高他们安全审计的工作效率.在这篇文章中, ...
- [luoguP1280] 尼克的任务(DP)
传送门 原本想着 f[i] 表示前 i 个任务的最优答案,但是不好转移 看了题解后,发现是 f[i] 表示前 i 分钟的最优解,看来还是不能死脑筋,思维得活跃,一个思路行不通就换一个思路. 把 f 数 ...
- [luoguP1433] 吃奶酪(DP || Dfs)
传送门 深搜加剪纸可A(O(玄学) 1274ms) ——代码 #include <cmath> #include <cstdio> #include <iostream& ...
- poj 2114 树的分治 可作模板
/* 啊啊啊啊啊啊啊本题证明一个问题,在实际应用中sort比qsort块 还有memset这类初始化能不加尽量别加,很浪费时间 原来的程序把qsort该成sort,去掉一个无用memset就a了时间不 ...