- 浏览: 183239 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-- 首先说个解决 ie兼容的标签
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
---aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SWFupload_Demo.aspx.cs"
Inherits="BookShop.Web.Test.SWFupload_Demo" %>
<!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>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<script src="../SWFupload/swfupload.js" type="text/javascript"></script>
<script src="../SWFupload/handlers.js" type="text/javascript"></script>
<script type="text/javascript">
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend Settings
upload_url: "/ashx/upload.ashx",//上传处理的文件
post_params : {
"ASPSESSID" : "<%=Session.SessionID %>"//通过post提交的数据
},
// File Upload Settings
file_size_limit : "2 MB",//限制的大小
file_types : "*.jpg;*.gif",
file_types_description : "JPG Images",
file_upload_limit : 0, // Zero means unlimited
// Event Handler Settings - these functions as defined in Handlers.js
// The handlers are not part of SWFUpload but are part of my website and control how
// my website reacts to the SWFUpload events.
swfupload_preload_handler : preLoad,
swfupload_load_failed_handler : loadFailed,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : ShowMsg,//上传成功调用的事件
upload_complete_handler : uploadComplete,
// Button settings
button_image_url : "/SWFupload/images/XPButtonNoText_160x22.png",
button_placeholder_id : "spanButtonPlaceholder",//显示按钮的位置
button_width: 160,
button_height: 22,
button_text : '<span class="button">请选择图片<span class="buttonSmall">(2 MB Max)</span></span>',//上传按钮的显示
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 : "/SWFupload/swfupload.swf", // Relative to this file
flash9_url : "/SWFupload/swfupload_FP9.swf", // Relative to this file
custom_settings : {
upload_target : "divFileProgressContainer"//显示上传文件和结果
},
// Debug Settings
debug: false
});
}
//在页面上显示上传成功的图片。
function ShowMsg(file, serverData)
{//serverData:从服务端返回的数据
var data=serverData.split(":");
if(data[0]=="ok"){
document.getElementById("imgok").src=data[1];
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="content">
<div id="swfu_container" style="margin: 0px 10px;">
<div>
<span id="spanButtonPlaceholder"></span>
</div>
<div id="divFileProgressContainer" style="height: 75px;">
</div>
</div>
<img id="imgok" />
</div>
</form>
</body>
</html>
--upload.ashx
using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.IO;
namespace BookShop.Web.ashx
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class upload : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
HttpPostedFile file = context.Request.Files["Filedata"];//获取上传的文件.
string fileName = Path.GetFileName(file.FileName); //获取文件名称.
string fileExtion = Path.GetExtension(file.FileName);//获取扩展名.
if (fileExtion == ".jpg")
{
//file.SaveAs(context.Server.MapPath("/FileUp/" + fileName));
//context.Response.Write("ok:/FileUp/" + fileName);
string saveDir = "/FileUp/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/";
Directory.CreateDirectory(Path.GetDirectoryName(context.Server.MapPath(saveDir)));//建立文件夹
string fullDir = saveDir + Common.Common.GetStreamMD5(file.InputStream) + fileExtion;//将文件进行MD5运算作为新的文件的名称.
file.SaveAs(context.Server.MapPath(fullDir));
context.Response.Write("ok:"+fullDir);
}
else
{
throw new Exception("类型错误!");
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
- SWFupload.rar (224 KB)
- 下载次数: 1
发表评论
文章已被作者锁定,不允许评论。
-
UMeditor
2015-01-07 16:50 392UMeditor,简称UM,是为满足广大门户网站对于简单发帖 ... -
使用SignalR构建一个最基本的web聊天室
2015-01-06 15:09 727使用SignalR,可以使用服务器消息推送到客户端,件demo ... -
lazyload异步加载图片
2014-12-24 15:18 488如果一个网页很长并且有很多图片的话,下载图片就需要很多时间 ... -
一台服务器访问另外一台服务器的共享目录
2014-12-19 10:50 562情况:A服务器的asp.ne程序需访问B服务器的共享目录, ... -
windows7 IIS7报错:如果要使用托管的处理程序,请安装 ASP.NET
2014-12-19 10:31 2385aspx 常见错误 CS0016: 未能写入输出文件“c:/ ... -
windows7 IIS7报错:如果要使用托管的处理程序,请安装 ASP.NET
2014-12-19 10:30 578windows7 IIS7报错:如果要使用托管的处理程序,请 ... -
Cookie小知识
2014-12-17 11:02 559如果cookie设置了过期时间,cookie就会保存在硬盘中 ... -
提升对ASP.NET网站性能和多并发的设计的讨论
2014-09-03 09:49 694对于如何提高应用程序 ... -
远程服务器返回错误: (500) 内部服务器错误 (解决方案)
2013-12-19 18:00 14004“/”应用程序中的服务器错误。 远程服务器返回错误: ... -
checbox,redio超强样式运用
2013-06-04 16:49 755<html xmlns="http://ww ... -
html页面获取参数加载数据,提高访问速度
2013-06-03 14:49 800如果你的网站很多数据是用jquery ajax获取的,那就没 ... -
一个避免用户重复点击按钮造成重复数据的小技巧
2013-01-13 16:13 1170<script> //启用 ... -
网页链接到QQ
2012-12-05 18:59 732<a target="_blank" ... -
评论的延迟加载
2012-11-10 18:34 739看verycd、cnbeta的评论区域很奇怪,每次看完了正文, ... -
id,name的小区别
2012-11-08 23:42 579很多时候,很多人喜欢只写id,不写name,不过这两个作用还是 ... -
SessionID的本质
2012-11-05 23:08 671一、客户端用cookie保存了sessionID 客户 ... -
进程管理运用,防盗链,权限限制
2012-11-05 22:58 552图片防止盗链 void Appl ... -
进程外session配置
2012-11-05 22:57 839进程外session StateServer 对象必须可序列 ... -
分页底层实现(超原理)
2012-10-16 22:19 921--样式 .paginator{ font: 12px ... -
网站盗链和网站防盗链
2012-10-07 14:42 805什么是盗链 “盗链”的定义是:此内容不在自己服务器上,而通 ...
相关推荐
PHPCMS V9 修改flash上传为H5上传方案,PHPCMS系统swfupload上传控件更换为基于html5的webuploader组件,Phpcms的上传模块是使用swfupload上传插件,具体写法是在控制器phpcms/modoules/attachemet/attachemts.php...
swfupload上传控件2.5版本,修复多个bug,支持多文件上传,大文件上传,可控制上传文件数目。
SwfUpload上传控件,编写一个样例,用java上传大文件,无缝刷新 上传大文件的效果,非常不错
jquery+SWFUpload+COS上传组件的使用 jquery+SWFUpload+COS上传组件的使用jquery+SWFUpload+COS上传组件的使用jquery+SWFUpload+COS上传组件的使用jquery+SWFUpload+COS上传组件的使用jquery+SWFUpload+COS上传组件...
做项目往往都需要上传文件...但微软自带的上传控件 往往并不能满足我们的需求 以前一直使用 FileUpload ,客户逐渐提出新的需求,迫使不得不改用新的办法 SWFUpload谁然依赖于flash,但在我看来,还是一个不错的选择
以前一直使用ASP.NET自带的FileUpload控件进行上传文件,发现经常出问题. 尽管在web.config文件中设置了maxRequestLength为很大,但还是不能上传大于2M的文件. 所有后来研究了下上传相关知识, 发现swfupload是一个不错...
SWFUpload上传组件,中文汉化版,很好用,可以学习下
SWFUpload上传组件的一个完整的例子,后台由Struts2完成,有上传进度显示,可以多文件上传,如果你想使用SWFUpload组件但还不知道怎样使用,可以下载下来运行一下试试,看一下源码就知道了。
swfUpload上传文件图片(多图片); 导入myeclipse直接运行即可;可扩展;
swfupload上传图片控件,支持删除。兼容浏览器ie7+,火狐,谷歌。上传界面类似QQ空间发表说说界面。
SwfUpload上传组件 ,适用于ASP.NET 2.0以上。使用时直接引用DLL。在原版基础上做了改进,增加了设置尺寸、返回原文件文件名的功能.使用方法:1、以自定义控件导入工程;2、将空间拖入制定位置;3、设置尺寸:width...
1 将上传文件随机命名上传到服务器 2 将随机名称与源文件名称写入数据库(解决中文文件名写入硬盘乱码的问题) 3 sql.sql 是测试用的表 作用:将文件名在本地命名如:[凤姐.jpg]上传,在选择文件时不会因为文件是中文...
相当不错的上传控件,只是多文件上传和进度显示
SWFUPLOAD上传组件.可以直接运行
swfupload控件实现flash文件上传。详尽的参数介绍等!
swfupload组件开发,实时体现上传进度; 调用程序是用javascript写的一个简单的类,调用非常方便; 可动态设置上传文件类型、大小、选择文件是多选还是单选以及每次最多允许上传的大小; 界面使用css+DIV布局兼容(IE6...
NULL 博文链接:https://name327.iteye.com/blog/1272476
swfupload多图片上传PHP多图上传组件FLASH+JS,SWF+JS文件+实例,非常使用的上传组件,带参数说明
swfupload 使用时会有ie兼容性问题。将这个js拷贝覆盖则能解决ie9ie10下面不能加载上传组件的兼容性问题。