void Application_BeginRequest(object sender, EventArgs e)
{
try {
string session_param_name = "ASPSESSID";
string session_cookie_name = "ASP.NET_SessionId";
if (HttpContext.Current.Request.Form[session_param_name] != null)
{
UpdateCookie(session_cookie_name, HttpContext.Current.Request.Form[session_param_name]);
}
else if (HttpContext.Current.Request.QueryString[session_param_name] != null)
{
UpdateCookie(session_cookie_name, HttpContext.Current.Request.QueryString[session_param_name]);
}
}
catch {
}
//此处是身份验证
try {
string auth_param_name = "AUTHID";
string auth_cookie_name = FormsAuthentication.FormsCookieName;
if (HttpContext.Current.Request.Form[auth_param_name] != null)
{
UpdateCookie(auth_cookie_name, HttpContext.Current.Request.Form[auth_param_name]);
}
else if (HttpContext.Current.Request.QueryString[auth_param_name] != null)
{
UpdateCookie(auth_cookie_name, HttpContext.Current.Request.QueryString[auth_param_name]);
}
}
catch { }
}
private void UpdateCookie(string cookie_name, string cookie_value)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(cookie_name);
if (null == cookie)
{
cookie = new HttpCookie(cookie_name);
}
cookie.Value = cookie_value;
HttpContext.Current.Request.Cookies.Set(cookie);//重新设定请求中的cookie值,将服务器端的session值赋值给它
}
this.hfAuth.Value = Request.Cookies[FormsAuthentication.FormsCookieName] == null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value; this.hfAspSessID.Value = Session.SessionID;
InitUpload: function(auth, AspSessID) {
$("#uploadify").uploadify({
uploader: 'Scripts/jqueryplugins/Infrastructure/uploadify.swf',
script: 'Handlers/ResourceHandler.ashx?OpType=UploadResource',
cancelImg: 'Scripts/jqueryplugins/Infrastructure/cancel.png',
queueID: 'fileQueue',
sizeLimit: '21480000000',
wmode: 'transparent ',
fileExt: '*.zip,*.jpg, *.rar,*.doc,*.docx,*.xls,*.xlsx,*.png,*.pptx,*.ppt,*.pdf,*.swf,*.txt',
auto: false,
multi: true,
scriptData: { ASPSESSID: AspSessID, AUTHID: auth },
if (this.LoginInfo == null)
{
// 解决uploadify兼容火狐谷歌浏览器上传问题
// 但是,此代码使系统有安全隐患,Flash程序请求该系统不需要验证
// 要解决此安全隐患,需要Flash程序传用户名和密码过来验证,但是该用户名和密码不能写在前端以便被不法用户看到
if (Request.UserAgent == "Shockwave Flash")
{
return;
}
else
{
filterContext.Result = RedirectToAction("LoginAgain", "Account", new { Area = "Auth" });
return;
}
}
$(function () {
$.ajax({
url: "/Auth/Account/GetUserNamePwd",
type: "POST",
dataType: "json",
data: {},
success: function (data) {
$("#uploadify").uploadify({
height: 25,
width: 100,
swf: '/Content/Plugins/UploadifyJs/uploadify.swf',
uploader: 'UploadFile',
formData: {
userName: data.data.userName, //ajax获取的用户名
pwd: data.data.pwd //ajax获取的密码
},
buttonText: '选择文件上传',
fileSizeLimit: '4MB',
fileTypeDesc: '文件',
fileTypeExts: '*.*',
queueID: 'fileQueue',
multi: true,
onUploadSuccess: function (fileObj, data, response) {
var d = eval("(" + data + ")");
$(".uploadify-queue-item").find(".data").html(" 上传完成");
$("#url").val(d.url);
$("#name").val(d.name);
},
onUploadError: function (event, ID, fileObj, errorObj) {
if (event.size > 4 * 1024 * 1024) {
alert('超过文件上传大小限制(4M)!');
return;
}
alert('上传失败');
}
}); //end uploadify
}
});
}); //end $
......
if (this.LoginInfo == null)
{
// 解决uploadify兼容火狐谷歌浏览器上传问题
// 但是,此代码使系统有安全隐患,Flash程序请求该系统不需要验证
// 要解决此安全隐患,需要Flash程序传用户名和密码过来验证,但是该用户名和密码不能写在前端以便被不法用户看到
if (Request.UserAgent == "Shockwave Flash")
{
string userName = Request.Params["userName"];
string pwd = Request.Params["pwd"];
if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(pwd))
{
AuthDAL authDAL = new AuthDAL();
sys_user user = authDAL.GetUserInfoByName(userName);
if (user != null && user.password == pwd)
{
return;
}
}
}
else
{
filterContext.Result = RedirectToAction("LoginAgain", "Account", new { Area = "Auth" });
return;
}
}
......
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String syscontext = request.getContextPath();
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path;
String sessionid = session.getId();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="<%=syscontext %>/webcontent/resourceManage/wallpapaer/uploadify/uploadify.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%=syscontext %>/webcontent/resourceManage/wallpapaer/uploadify/jquery.uploadify-3.1.min.js"></script>
<!-- 注意我使用的jquery uploadify版本-->
<script type="text/javascript">
//用来计算上传成功的图片数
var successCount = 1;
$(function() {
var uploadUrl = '<%=basePath%>/uploadresource.do;jsessionid=<%=sessionid%>?Func=uploadwallpaper2Dfs';
var swfUrl2 = "<%=basePath%>/webcontent/resourceManage/wallpapaer/uploadify/uploadify.swf";
$('#file_upload').uploadify({
'swf' : swfUrl2,
'uploader' : uploadUrl,
// Put your options here
'removeCompleted' : false,
'auto' : false,
'method' : 'post',
'onUploadSuccess' : function(file, data, response) {
add2SuccessTable(data);
}
});
});
/**
* 将成功上传的图片展示出来
*/
function add2SuccessTable(data){
var jsonObj = JSON.parse(data);
for(var i =0; i < jsonObj.length; i++){
var oneObj = jsonObj[i];
var fileName = oneObj.fileName;
var imgUrl = oneObj.imgUrl;
var td_FileName = "<td>"+fileName+"</td>";
var td_imgUrl = "<td><img width='150' src='"+imgUrl+"'></img></td>";
var oper = "<td><input type='button' value='删除' onclick='deleteRow("+successCount+")'/></td>";
var tr = "<tr id='row"+successCount+"'>"+successCount+td_FileName+td_imgUrl+oper+"</tr>";
$("#successTable").append(tr);
successCount++;
}
}
function deleteRow(i){
$("#row"+i).empty();
$("#row"+i).remove();
}
</script>
<title>Insert title here</title>
</head>
<body>
<input type="file" name="file_upload" id="file_upload" />
<p>
<a href="javascript:$('#file_upload').uploadify('upload','*')">开始上传</a>
<a href="javascript:$('#file_upload').uploadify('cancel', '*')">取消所有上传</a>
</p>
<table id="successTable">
<tr>
<td>文件名</td>
<td>图片</td>
<td>操作</td>
</tr>
</table>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有