用.net改写的uploadify多文件上传控件

有图真相:

 

ASP.NET代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UploadV2.aspx.cs" Inherits="TestUpload.UploadV2" %>

<!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 runat="server">
    <title></title>
    <link href="Scripts/uploadify-3.2.1/uploadify.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery/jquery-1.8.1.min.js" type="text/javascript"></script>
    <script src="Scripts/uploadify-3.2.1/jquery.uploadify.min.js" type="text/javascript"></script>
   <script type="text/javascript">
        $(function () {
            $(#file_upload).uploadify({
                buttonText: 上传文件,
                width: 70, 
                height: 20, 
                swf: Scripts/uploadify-3.2.1/uploadify.swf,
                uploader: uploadhandler.ashx,
                 onUploadSuccess : function(file, data, response) {
                        alert(data);
                    },
                    onUploadComplete: function (file) {
                        alert(The file  + file.name +  finished processing.);
                    }


            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:FileUpload ID="file_upload" runat="server" />
    </div>
    </form>
</body>
</html>

 

C#代码:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Web;
 5 
 6 namespace TestUpload
 7 {
 8     /// <summary>
 9     /// UploadHandler 的摘要说明
10     /// </summary>
11     public class UploadHandler : IHttpHandler
12     {
13 
14         public void ProcessRequest(HttpContext context)
15         {
16             context.Response.ContentType = "text/plain";
17             context.Response.Charset = "utf-8";
18 
19             HttpPostedFile file = context.Request.Files["Filedata"];
20             string oldFileName = "";
21             string newFileName = "";
22             if (file != null)
23             {
24                 oldFileName = file.FileName;//原文件名     
25                 newFileName = Guid.NewGuid().ToString();
26                 int size = file.ContentLength;//附件大小
27 
28                 //context.Response.Write("{ Success = true, FileName = \"" + oldFileName + "\", SaveName = \"" + newFileName + "\" }");
29 
30             }
31             else
32             {
33                 //context.Response.Write("{ Success = false, Message = \"请选择要上传的文件!\" }");
34             }
35             context.Response.Write("上传的文件是:" + oldFileName);
36             //return Json(new { Success = true, FileName = fileName, SaveName = saveName });
37         }
38 
39         public bool IsReusable
40         {
41             get
42             {
43                 return false;
44             }
45         }
46     }
47 }

需要完整源码,请联系邮箱:[email protected]

用.net改写的uploadify多文件上传控件,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。