Uploadify上传Session丢失问题

只要在使用uploadify 上传的时候,只要将sessionId传过去就可以了。


在jsp中如何取sessionId:${pageContext.session.id}

<input type="hidden" id="sessionId" value="${pageContext.session.id}" />


$("").uploadify({
'formData' : {'ASPSESSID':$("#sessionId").val()}
});



uploadify的官网解释:http://www.uploadify.com/documentation/uploadify/using-sessions-with-uploadify/

Using Sessions with Uploadify

In Uploadify, the Flash file is what communicates with the backend script. Because of a bug in Flash, the session cookie is not picked up by the Flash file. To circumvent this, you will need to pass the session data via theformDataoption. To do this in PHP, use the following code when initializing Uploadify on the front-end page:

$('#file_upload).uploadify({
    // Your normal options here
    formData : { '<?php echo session_name();?>' : '<?php echo session_id();?>' }
});


This will send the session ID as the value of a post (or get, depending on the method you’ve set) parameter to the server-side upload script (uploadify.php) with a key of whatever yoursession_name is.

At the beginning of your uploadify.php script, you can use the following code to load the proper session:

This will start the proper session and allow you to use any session variables as expected.

For an extra layer of security, you can call session_regenerate_id() in some PHP code that is fired when your uploads are done.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值