不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
SWFUpload+.NET(C#)使用示例
编辑:dnawo 日期:2009-06-12
Default.aspx:
upload.ashx:
最后,web.config中configuration增加以下节点:
完成!点击下载示例
SWFUpload官方站点:http://swfupload.org/
SWFUpload源码下载:http://swfupload.googlecode.com/
复制内容到剪贴板
程序代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>SWFUpload示例-Mzwu.Com</title>
<script type="text/javascript" src="js/swfupload.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend Settings
upload_url: "upload.ashx",
post_params : {
"ASPSESSID" : "<%=Session.SessionID %>"
},
// File Upload Settings
file_size_limit : "5 MB",
file_types : "*.jpg",
file_types_description : "JPG Images",
// Event Handler Settings
file_dialog_complete_handler : function(numFilesSelected, numFilesQueued) { if (numFilesQueued > 0)this.startUpload();},
upload_success_handler : function(file,responseText){alert(file.name + " saveas " + responseText);},
// Button settings
button_image_url : "images/XPButtonNoText_160x22.png",
button_placeholder_id : "spanButtonPlaceholder",
button_width: 160,
button_height: 22,
button_text : '上传文件(<3M)',
button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 1,
button_text_left_padding: 5,
// Flash Settings
flash_url : "swf/swfupload.swf", // Relative to this file
// Debug Settings
debug: false
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="spanButtonPlaceholder"></div>
</div>
</form>
</body>
</html>
<!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>SWFUpload示例-Mzwu.Com</title>
<script type="text/javascript" src="js/swfupload.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend Settings
upload_url: "upload.ashx",
post_params : {
"ASPSESSID" : "<%=Session.SessionID %>"
},
// File Upload Settings
file_size_limit : "5 MB",
file_types : "*.jpg",
file_types_description : "JPG Images",
// Event Handler Settings
file_dialog_complete_handler : function(numFilesSelected, numFilesQueued) { if (numFilesQueued > 0)this.startUpload();},
upload_success_handler : function(file,responseText){alert(file.name + " saveas " + responseText);},
// Button settings
button_image_url : "images/XPButtonNoText_160x22.png",
button_placeholder_id : "spanButtonPlaceholder",
button_width: 160,
button_height: 22,
button_text : '上传文件(<3M)',
button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 1,
button_text_left_padding: 5,
// Flash Settings
flash_url : "swf/swfupload.swf", // Relative to this file
// Debug Settings
debug: false
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="spanButtonPlaceholder"></div>
</div>
</form>
</body>
</html>
upload.ashx:
复制内容到剪贴板
程序代码

<%@ WebHandler Language="C#" Class="Upload" %>
using System;
using System.Web;
using System.IO;
public class Upload : IHttpHandler {
public void ProcessRequest (HttpContext context) {
try
{
HttpPostedFile upload = context.Request.Files["Filedata"];
string name = DateTime.Now.Ticks.ToString() + Path.GetExtension(upload.FileName);
upload.SaveAs(Path.Combine(context.Server.MapPath("upload"), name));
context.Response.StatusCode = 200;
context.Response.Write(name);
}
catch { }
}
public bool IsReusable {
get {
return false;
}
}
}
using System;
using System.Web;
using System.IO;
public class Upload : IHttpHandler {
public void ProcessRequest (HttpContext context) {
try
{
HttpPostedFile upload = context.Request.Files["Filedata"];
string name = DateTime.Now.Ticks.ToString() + Path.GetExtension(upload.FileName);
upload.SaveAs(Path.Combine(context.Server.MapPath("upload"), name));
context.Response.StatusCode = 200;
context.Response.Write(name);
}
catch { }
}
public bool IsReusable {
get {
return false;
}
}
}
最后,web.config中configuration增加以下节点:
复制内容到剪贴板
程序代码

<location path="Upload.ashx">
<system.web>
<httpRuntime maxRequestLength="3100" executionTimeout="300" />
</system.web>
</location>
<system.web>
<httpRuntime maxRequestLength="3100" executionTimeout="300" />
</system.web>
</location>
完成!点击下载示例
SWFUpload官方站点:http://swfupload.org/
SWFUpload源码下载:http://swfupload.googlecode.com/
评论: 0 | 引用: 0 | 查看次数: 7348
发表评论
请登录后再发表评论!