gpt4 book ai didi

jquery - Asp.net 中未返回 session ID

转载 作者:行者123 更新时间:2023-12-01 08:20:19 27 4
gpt4 key购买 nike

我正在尝试使用 plupload JqueryUI Widget uploader 并尝试使用 session ID 上传图像,并且它保存在各自的 session ID 下,但是当 OncompleteAll (即当我绑定(bind)它们时)事件时,我尝试使用相同的 session 显示它们的文件名ID 没有发生。

谁能告诉我我犯了什么错误?

这是我的代码:

       <script type="text/javascript">
$(function () {
$("#uploader").plupload({
runtimes: 'gears,flash,silverlight,browserplus,html5',
url: 'upload.aspx',
max_file_size: '10mb',
chunk_size: '1mb',
unique_names: true,

// Resize images on clientside if we can
resize: { width: 320, height: 240, quality: 90 },

// Specify what files to browse for
filters: [
{ title: "Image files", extensions: "jpg,gif,png" },
{ title: "Zip files", extensions: "zip" }
],

// Flash settings
flash_swf_url: 'js/plupload.flash.swf',

// Silverlight settings
silverlight_xap_url: 'js/plupload.silverlight.xap'
});


// Client side form validation
$('form').submit(function (e) {
var uploader = $('#uploader').plupload('getUploader');

// Files in queue upload them first
if (uploader.files.length > 0) {
// When all files are uploaded submit form
uploader.bind('StateChanged', function () {
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
$('form')[0].submit();
}
});

uploader.start();
} else
alert('You must at least upload one file.');

return false;
});

var uploader = $('#uploader').plupload('getUploader');
uploader.bind('FileUploaded', function (up, file, res) {
$('#showfilelist').append("<div id=" + file.id + "><a href='uploads/" & Session("ID") & "/" + file.name + "'><br>" + file.name + "</div>");

});
});
</script>

这是处理程序文件:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsNothing(Request.Form("chunk")) = False Then
If Session("ID") Is Nothing Then
Session("ID") = Guid.NewGuid.ToString
IO.Directory.CreateDirectory(Server.MapPath("uploads/" & Session("ID")))
End If
Dim chunk As Integer = Request.Form("chunk")
Dim chunks As Integer = Request.Form("chunks")
Dim filename As String = Request.Form("name")
If chunk = 0 Then
Request.Files(0).SaveAs(Server.MapPath("uploads/") & Session("ID") & "/" & Request.Files(0).FileName)
Else
Dim OutputStream As New IO.FileStream(Server.MapPath("uploads/") & Session("ID") & "/" & Request.Files(0).FileName, IO.FileMode.Append)
Dim InputBytes(Request.Files(0).ContentLength) As Byte
Request.Files(0).InputStream.Read(InputBytes, 0, Request.Files(0).ContentLength)
OutputStream.Write(InputBytes, 0, InputBytes.Length - 1)
OutputStream.Close()
End If
End If
End Sub

此处显示文件名:

<div id="showfilelist">
</div>

最佳答案

我必须承认我对 plupload 不太熟悉。然而,使用Uploadify时, session id没有传回的原因是flash没有传回 session cookie。

抱歉编辑(新链接,旧链接有安全缺陷)

这里有一些可以帮助您的内容:

Uploadify ashx file Context.Session gets null

关于jquery - Asp.net 中未返回 session ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7738066/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com