Uploadify jquery+falsh+UploadHandler.ashx

官方网:http://www.uploadify.com/ 只有PHP版本

对于我们.net的来说是一个遗憾!现在奉献一个c#版本,希望对大家有用。

看代码其实很简单,在做这个之前遇到许多问题,特别是在IHttpHandler 里面,只有经历过了才会体会到,还是给解决了!

3

直接运行html出现下面错误  要在vs运行下才没有下面错误

3.1 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<! DOCTYPE  html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html  xmlns="http://www.w3.org/1999/xhtml">
< head >
< meta  http-equiv="Content-Type" content="text/html; charset=utf-8" />
< title >Uploadify</ title >
< link  href="css/default.css" rel="stylesheet" type="text/css" />
< link  href="css/uploadify.css" rel="stylesheet" type="text/css" />
< script  type="text/javascript" src="scripts/jquery-1.3.2.min.js"></ script >
< script  type="text/javascript" src="scripts/swfobject.js"></ script >
< script  type="text/javascript" src="scripts/jquery.uploadify.v2.1.0.min.js"></ script >
< script  type="text/javascript">
$(document).ready(function() {
  $("#uploadify").uploadify({
   'uploader'       : 'scripts/uploadify.swf',
   'script'         : 'scripts/UploadHandler.ashx',
   'cancelImg'      : 'scripts/cancel.png',
   'folder'         : 'uploads',
   'queueID'        : 'fileQueue',
   'sizeLimit'      : '5242880',//5M
   'auto'           : false,
   'multi'          : true ,
   'onError'        : function (a, b, c, d)
   {
   if (d.status == 404)
   alert('Could not find upload script. Use a path relative to: '+'<?= getcwd() ?>');
   else if (d.type === "HTTP")
   alert('error '+d.type+": "+d.status);
   else if (d.type ==="File Size")
   alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
   else
   alert('error '+d.type+": "+d.info);
   }
  });
});
</ script >
</ head >
 
< body >
< div  id="fileQueue"></ div >
< input  type="file" name="uploadify" id="uploadify" />
< p >
< a  href="javascript:$('#uploadify').uploadifyUpload()">Upload</ a >|
 
< a  href="javascript:$('#uploadify').uploadifyClearQueue()">Cancel All Uploads</ a >
</ p >
</ body >
</ html >

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<%@ WebHandler Language= "C#"  Class= "UploadHandler"  %>
using  System;
using  System.IO;
using  System.Net;
using  System.Web;
 
public  class  UploadHandler : IHttpHandler
{
     public  void  ProcessRequest(HttpContext  context)
     {
         context.Response.ContentType = "text/plain" ;
         context.Response.Charset = "utf-8" ;
         HttpPostedFile oFile = context.Request.Files[ "Filedata" ];
         string   strUploadPath = HttpContext.Current.Server.MapPath(@context.Request[ "folder" ])+ "\\" ;
         if  (oFile != null )
         {
             if  (!Directory.Exists(strUploadPath))
             {
                 Directory.CreateDirectory(strUploadPath);
             }
             oFile.SaveAs(strUploadPath + oFile.FileName);
             context.Response.Write( "1" );
             
         }
         else
         {
             context.Response.Write( "0" );
         }
     }
     public  bool  IsReusable
     {
         get   { return  false ; }
     }
}

2011-3-18 
其他版本:blueimp-jQuery-File-Upload
  c#   在54楼 下载  不同上面那个!!

 

点击Flash按钮无法打开链接的解决方案:

http://www.cnblogs.com/zengxiangzhan/archive/2009/09/12/1565349.html

 

    本文转自曾祥展博客园博客,原文链接:http://www.cnblogs.com/zengxiangzhan/archive/2009/12/14/1623221.html,如需转载请自行联系原作者


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
uploadify 2.1.0 是一种用于在 Spring MVC 中实现文件上传的插件。 Spring MVC 是一个基于 Java 的 MVC(模型-视图-控制器)框架,用于构建 Web 应用程序。它提供了一种优雅的方式来处理客户端请求和响应,并支持各种功能,如路由、表单处理和文件上传。 uploadify 2.1.0 是一种用于在前端页面上实现文件上传的 JavaScript 插件。它具有易用性和灵活性的特点,可以与 Spring MVC 集成,实现文件上传功能。 要在 Spring MVC 中使用 uploadify 2.1.0,首先需要在前端页面引入 uploadifyJavaScript 文件,并创建一个上传按钮和一个用于显示上传进度的容器。 然后,在后端的 Spring MVC 控制器中,创建一个处理文件上传的方法。可以使用 Spring 的 MultipartFile 类型来接收上传的文件。在处理方法中,可以利用 MultipartFile 类提供的方法来获取文件的相关信息,如文件名、大小和内容。 处理方法可以进行一些上传文件的逻辑,如检查文件类型、大小或保存文件到服务器的指定路径。可以利用 Spring MVC 的文件上传功能,来处理上传的文件,并返回相应的响应结果给前端页面。 最后,可以在页面上通过监听 uploadify 的一些回调事件,来处理上传完成后的操作,如显示上传成功或失败的消息,或刷新页面以显示最新的上传文件列表。 总结来说,uploadify 2.1.0 和 Spring MVC 可以很好地配合使用,实现在 Web 应用程序中的文件上传功能,提升用户体验和数据操作的便利性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值