1
uploadify를 사용하여 파일을 업로드하고 파일을 저장하고 데이터베이스에 경로를 저장하려고하므로 세션에서 경로를 저장하고 사용자가 양식을 제출 한 후에 저장합니다. Internet Explorer에서 작동하지만 Firefox에서는 세션 ID가 변경되어 작동하지 않습니다.Firefox에서 세션 ID가 변경되는 이유
이 문제를 해결하는 방법은 무엇입니까?
uploadify를 사용하여 파일을 업로드하고 파일을 저장하고 데이터베이스에 경로를 저장하려고하므로 세션에서 경로를 저장하고 사용자가 양식을 제출 한 후에 저장합니다. Internet Explorer에서 작동하지만 Firefox에서는 세션 ID가 변경되어 작동하지 않습니다.Firefox에서 세션 ID가 변경되는 이유
이 문제를 해결하는 방법은 무엇입니까?
서버가 세션을 식별 할 수 없도록 uploadify 플러그인이 쿠키를 보내지 않습니다.
<script type="text/javascript">
$(function() {
$('#file').uploadify({
uploader: '<%= Url.Content("~/Scripts/jquery.uploadify-v2.1.4/uploadify.swf") %>',
script: '<%= Url.Action("Index") %>',
folder: '/uploads',
scriptData: { ASPSESSID: '<%= Session.SessionID %>' },
auto: true
});
});
</script>
<% using (Html.BeginForm()) { %>
<input id="file" name="file" type="file" />
<input type="submit" value="Upload" />
<% } %>
이 파일과 함께 요청에 ASPSESSID 매개 변수를 추가합니다 : 이것을 달성하는 한 가지 방법은 요청 매개 변수로 sessionId가 포함되도록 scriptData
매개 변수를 사용하는 것입니다. 다음으로 서버에서 세션을 재구성해야합니다.
protected void Application_BeginRequest(object sender, EventArgs e)
{
string sessionParamName = "ASPSESSID";
string sessionCookieName = "ASP.NET_SessionId";
if (HttpContext.Current.Request[sessionParamName] != null)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[sessionCookieName];
if (null == cookie)
{
cookie = new HttpCookie(sessionCookieName);
}
cookie.Value = HttpContext.Current.Request[sessionParamName];
HttpContext.Current.Request.Cookies.Set(cookie);
}
}
을 마지막으로 업로드를받을 컨트롤러 액션은 세션을 사용할 수 있습니다 : 이것은 Global.asax
에 Application_BeginRequest
방법으로 수행 할 수의
[HttpPost]
public ActionResult Index(HttpPostedFileBase fileData)
{
// You could use the session here
var foo = Session["foo"] as string;
return View();
}
가능한 중복 [세션 및 uploadify] (HTTP를 : //stackoverflow.com/questions/1284666/sessions-and-uploadify) –
감사합니다. 그러나 저는 PHP를 모르겠습니다. – Mazen