标签:style blog class c code java
有图真相:
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 }
需要完整源码,请联系邮箱:wag.wag@163.com
用.net改写的uploadify多文件上传控件,布布扣,bubuko.com
标签:style blog class c code java
原文地址:http://www.cnblogs.com/wroad/p/3738147.html