0.先去官网下载插件 下载uploadify3.2.1插件

解压后只需要一下文件:

(1) jQuery.uploadify.min.js

(2) uploadify.css

(3) uploadify.swf

但是运用到网站后需要应用jquery 1.4以上版本

1.ASP.NET Web Form

简单配置.ASPX文件

  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head runat="server">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  4. <title></title>
  5. <link type="text/css" rel="stylesheet" href="Content/uploadify/uploadify.css" />
  6. <script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>
  7. <script type="text/javascript" src="Content/uploadify/jquery.uploadify.min.js"></script>
  8. </head>
  9. <body>
  10. <input id="file_upload" name="file_upload" type="file" multiple="multiple"/>
  11. <script type="text/javascript">
  12. $(document).ready(function () {
  13. $("#file_upload").uploadify({
  14. 'swf': 'Content/uploadify/uploadify.swf',
  15. 'auto': true,
  16. 'multi': true,
  17. 'uploader': 'UploadHandler.ashx',//指定一般处理程序 执行上传后的文件处理
  18. });
  19. });
  20. </script>
  21. </body>
  22. </html>

创建一般处理程序 重新 ProcessRequest

  1. public void ProcessRequest(HttpContext context)
  2. {
  3. context.Response.ContentType = "text/plain";
  4. context.Response.Charset="UTF-8";
  5. HttpPostedFile file=context.Request.Files["Filedata"];
  6. //这个Filedata 是uploadify fileObjName项的默认值
  7. string path = HttpContext.Current.Server.MapPath("~/LoadFiles") + "\\";
  8. if (file != null)
  9. {
  10. file.SaveAs(path+file.FileName);
  11. }
  12. }

2.ASP.NET MVC3

配置View

  1. <link type="text/css" rel="stylesheet" href=@Url.Content("~/Content/uploadify/uploadify.css") />
  2. <script type="text/javascript" src=@Url.Content("~/Scripts/jquery-1.7.1.min.js")></script>
  3. //我试了很多次,一定要引用Url.Content辅助方法才行
  4. <script type="text/javascript" src=@Url.Content("~/Content/uploadify/jquery.uploadify.min.js")></script>
  5. <script type="text/javascript">
  6. $(function () {
  7. $("#file_upload").uploadify({
  8. 'swf': '@Url.Content("~/Content/uploadify/uploadify.swf")',
  9. 'auto': true,
  10. 'multi': true,
  11. 'uploader': 'Person/Upload'
  12. });
  13. });
  14. </script>
  15. <input id="file_upload" name="file_upload" type="file" multiple="multiple"/>

编写Action 只要捕获到Filedata接算是成功了

  1. [HttpPost]
  2. public ActionResult Upload(HttpPostedFileBase Filedata)
  3. //Filedata不能改名 因为它是uploadify fileObjName项的默认值 除非修改 fileObjName项的默认值
  4. //不然会报错
  5. {
  6. if (Filedata != null)
  7. {
  8. //do something.
  9. }
  10. return View();
  11. }

3.ASP.net MVC4

配置View

  1. <link type="text/css" rel="stylesheet" href=@Url.Content("~/Content/uploadify/uploadify.css") />
  2. <script type="text/javascript" src=@Url.Content("~/Scripts/jquery-1.7.1.min.js")></script>
  3. <script type="text/javascript" src=@Url.Content("~/Content/uploadify/jquery.uploadify.min.js")></script>
  4. <script type="text/javascript">
  5. $(function () {
  6. $("#file_upload").uploadify({
  7. 'swf': '@Url.Content("~/Content/uploadify/uploadify.swf")',
  8. 'auto': true,
  9. 'multi': true,
  10. <span style="color:#FF0000">'uploader': '@Url.Action("Upload","Person")',</span>
  11. 'folder': 'UpLoadFiles'
  12. });
  13. });
  14. </script>
  15. <input id="file_upload" name="file_upload" type="file" multiple="multiple"/>
  1. <span style="font-size:18px; color:#3366FF">:其实和MVC3差不多,只是有一个地方不明白,在MVC4中</span><span style="color:#3366FF">
  2. 'uploader': '@Url.Action("Upload","Person")' 写成
  3. </span><pre name="code" class="html"><span style="color:#3366FF">   'uploader': 'Person/Upload' 会报错。。。。
  4. </span></pre>

编写Action 和MVC3 一样

  1. [HttpPost]
  2. public ActionResult Upload(HttpPostedFileBase Filedata)
  3. {
  4. if (Filedata != null)
  5. {
  6. //do something
  7. }
  8. return View();
  9. }

以上只是uploadify插件的简单运用,其还有更多的功能需要慢慢学习

uploadify 3.2.1 参数项:

  1. <span style="font-size:14px">// Required Settings
  2. id       : $this.attr('id'), // The ID of the DOM object
  3. swf      : 'uploadify.swf',  // The path to the uploadify SWF file
  4. uploader : 'uploadify.php',  // The path to the server-side upload script
  5. // Options
  6. auto            : true,               // Automatically upload files when added to the queue
  7. buttonClass     : '',                 // A class name to add to the browse button DOM object
  8. buttonCursor    : 'hand',             // The cursor to use with the browse button
  9. 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
  10. buttonText      : 'SELECT FILES',     // The text to use for the browse button
  11. checkExisting   : false,              // The path to a server-side script that checks for existing files on the server
  12. debug           : false,              // Turn on swfUpload debugging mode
  13. fileObjName     : 'Filedata',         // The name of the file object to use in your server-side script
  14. fileSizeLimit   : 0,                  // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
  15. fileTypeDesc    : 'All Files',        // The description for file types in the browse dialog
  16. fileTypeExts    : '*.*',              // Allowed extensions in the browse dialog (server-side validation should also be used)
  17. height          : 30,                 // The height of the browse button
  18. itemTemplate    : false,              // The template for the file item in the queue
  19. method          : 'post',             // The method to use when sending files to the server-side upload script
  20. multi           : true,               // Allow multiple file selection in the browse dialog
  21. formData        : {},                 // An object with additional data to send to the server-side upload script with every file upload
  22. preventCaching  : true,               // Adds a random value to the Flash URL to prevent caching of it (conflicts with existing parameters)
  23. progressData    : 'percentage',       // ('percentage' or 'speed') Data to show in the queue item during a file upload
  24. queueID         : false,              // The ID of the DOM object to use as a file queue (without the #)
  25. queueSizeLimit  : 999,                // The maximum number of files that can be in the queue at one time
  26. removeCompleted : true,               // Remove queue items from the queue when they are done uploading
  27. removeTimeout   : 3,                  // The delay in seconds before removing a queue item if removeCompleted is set to true
  28. requeueErrors   : false,              // Keep errored files in the queue and keep trying to upload them
  29. successTimeout  : 30,                 // The number of seconds to wait for Flash to detect the server's response after the file has finished uploading
  30. uploadLimit     : 0,                  // The maximum number of files you can upload
  31. width           : 120,                // The width of the browse button</span>

:在3.2.1版本中和以前不一样不要乱用像script、cancelImg这样的参数项,是没有用的,反而会把自己弄糊涂

uploadify3.2.1版插件在ASP.NET中的使用的更多相关文章

  1. [转]仿World Wind构造自己的C#版插件框架——WW插件机制精简改造

    很久没自己写东西啦,早该好好总结一下啦!一个大师说过“一个问题不应该被解决两次!”,除了一个好脑筋,再就是要坚持总结. 最近需要搞个系统的插件式框架,我参照World Wind的插件方式构建了个插件框 ...

  2. 关于Asp.Net中的编程实现下载

    经常在论坛看见有人求Asp.Net中编程实现下载的代码,有些还希望能断点续传什么的.其实问题的关键在于权限.B/S和C/S不仅仅是外观上的区别而已. 下载,顾名思义是客户端要下,所以载.你硬塞給人家那 ...

  3. ASP.NET中后台数据和前台控件的绑定

    关于ASP.NET中后台数据库和前台的数据控件的绑定问题 最近一直在学习个知识点,自己创建了SQL Server数据库表,想在ASP.NET中连接数据库,并把数据库中的数据显示在前台,注意,这里的数据 ...

  4. 在 ASP.NET 中创建数据访问和业务逻辑层(转)

    .NET Framework 4 当在 ASP.NET 中处理数据时,可从使用通用软件模式中受益.其中一种模式是将数据访问代码与控制数据访问或提供其他业务规则的业务逻辑代码分开.在此模式中,这两个层均 ...

  5. ASP.NET中UEditor使用

    ASP.NET中UEditor使用 0.ueditor简介 UEditor是由百度WEB前端研发部开发的所见即所得的开源富文本编辑器,具有轻量.可定制.用户体验优秀等特点.开源基于BSD协议,所有源代 ...

  6. ASP.NET 中的 authentication(验证)与authorization(授权)

    这两个东西很绕口,也绕脑袋. 一般来说,了解authentication(验证)的用法即可,用于自定义的用户验证. authorization(授权)主要通过计算机信息来控制. “*”:所有用户: “ ...

  7. ASP.NET中数据棒图,饼图,柱状图的实现

    Web中绘制图形的方法大致有: 1. VML方式:功能强大,但是非常麻烦. 推荐:http://www.elook.net.cn/vml/ 2.使用控件:Dandus, Aspose.chart,Co ...

  8. 也谈Asp.net 中的身份验证

    钱李峰 的这篇博文<Asp.net中的认证与授权>已对Asp.net 中的身份验证进行了不错实践.而我这篇博文,是从初学者的角度补充了一些基础的概念,以便能有个清晰的认识. 一.配置安全身 ...

  9. 【译】在ASP.NET中创建PDF-iTextSharp起步

    原文 [译]在ASP.NET中创建PDF-iTextSharp起步 .Net framework 中自身并不包含可以和pdf打交道的方法.所以,当你需要你的ASP.Net Web应用程序中包含创建或与 ...

随机推荐

  1. 执行join_paired_ends.py报错Cannot find fastq-join

    通过 conda 安装 qiime 1后,在执行join_paired_ends.py时报错: burrito.util.ApplicationNotFoundError: Cannot find f ...

  2. Redis系列(七)--Sentinel哨兵模式

    在上一篇文章了解了主从复制,主从复制本身的容错性很差,一旦master挂掉,只能进行手动故障转移,很难完美的解决这个问题 而本文讲解的sentinel可以解决这个问题 Redis sentinel示意 ...

  3. 用Docker构建Nginx镜像

    1构建Nginx镜像 1建立工作目录 [root@localhost ]# mkdir 1nginx [root@localhost 1nginx]# cd 1nginx/ [root@localho ...

  4. 深入理解DOM事件类型系列——剪贴板事件

    定义 剪贴板操作包括剪切(cut).复制(copy)和粘贴(paste)这三个操作,快捷键分别是ctrl+x.ctrl+c.ctrl+v.当然也可以使用鼠标右键菜单进行操作 对象事件 关于这3个操作共 ...

  5. UVA - 1611 Crane (思路题)

    题目: 输入一个1~n(1≤n≤300)的排列,用不超过96次操作把它变成升序.每次操作都可以选一个长度为偶数的连续区间,交换前一半和后一半.输出每次操作选择的区间的第一个和最后一个元素. 思路: 注 ...

  6. <SpringMvc>入门三 参数绑定

    1.get请求 <%--请求参数的绑定--%> <%--get请求参数--%> <a href="/param/testParam1?username=tom& ...

  7. python实现字符串转换整数

    实现一个函数,使其能将字符串转换成整数. 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止. 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续 ...

  8. pandas 处理 excel

    先写下来,以免后续忘记,有很多都是之前用过的, 依旧忘!!! 嘤嘤嘤 data_file = pandas.read_excel('/imporExcel/2017_7_7.xlsx',sep = ' ...

  9. 洛谷 1062 NOIP2006普及T4 数列

    [题解] 鲜活的水题..我们把数列换成k进制的,发现数列是001,010,011,100,101,110,111...,而第m项用k进制表示的01串刚好就是m的二进制的01串.于是我们预处理k的幂,把 ...

  10. [bzoj4726][POI2017][Sabota?] (树形dp)

    Description 某个公司有n个人, 上下级关系构成了一个有根树.其中有个人是叛徒(这个人不知道是谁).对于一个人, 如果他 下属(直接或者间接, 不包括他自己)中叛徒占的比例超过x,那么这个人 ...