gpt4 book ai didi

java - Firefox 的 swfupload 中的 UploadError 403

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:41:55 25 4
gpt4 key购买 nike

我正在尝试使用 swfuploder 上传文件,它在 IE 中工作正常。但它在 Firefox 中出现“UploadError 403”。我正在使用 apache-tomcat-6.0.16 并且也无法访问 .htaccess 文件。

这是我用于 swfupload 的代码。

<!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>
<title>SWFUpload Demos - Simple Demo</title>
<link href="../css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/swfupload/demos/swfupload/swfupload.js"></script>
<script type="text/javascript" src="../js/swfupload/demos/simpledemo/js/swfupload.queue.js"></script>
<script type="text/javascript" src="../js/swfupload/demos/simpledemo/js/fileprogress.js"></script>
<script type="text/javascript" src="../js/swfupload/demos/simpledemo/js/handlers.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function() {
var settings = {
flash_url : "../js/swfupload/demos/swfupload/swfupload.swf",
upload_url: "upload_pages/uploader.jsp",
post_params: {"PHPSESSID" : ""},
file_size_limit : "100 MB",
file_types : "*.*",
file_types_description : "All Files",
file_upload_limit : 100,
file_queue_limit : 0,
custom_settings : {
progressTarget : "fsUploadProgress",
cancelButtonId : "btnCancel"
},
debug: true,
prevent_swf_caching: true,

// Button settings
button_image_url: "../js/swfupload/demos/simpledemo/images/TestImageNoText_65x29.png",
button_width: "65",
button_height: "29",
button_placeholder_id: "spanButtonPlaceHolder",
button_text: '<span class="theFont">Upload</span>',
button_text_style: ".theFont { font-size: 16; }",
button_text_left_padding: 12,
button_text_top_padding: 3,

// The event handler functions are defined in handlers.js
file_queued_handler : fileQueued,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_start_handler : uploadStart,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete,
queue_complete_handler : queueComplete
};

swfu = new SWFUpload(settings);
};
</script>
</head>
<body>
<div id="content">
<h2>File Upload</h2>
<form id="form1" method="post" enctype="multipart/form-data">
<div class="fieldset flash" id="fsUploadProgress">
<span class="legend">Upload Queue</span>
</div>
<div id="divStatus">0 Files Uploaded</div>
<div>
<span id="spanButtonPlaceHolder"></span>
<input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
</div>
</form>
</div>
</body>
</html>

我已经尝试使用“upload_url”的绝对和相对 url,但出现相同的错误“uploadError 403”。但它适用于 IE。

最佳答案

HTTP 状态码 403 表示 Forbidden .这是一个身份验证错误。该请求需要经过身份验证的用户(登录用户),但该用户不在 session 中,或者找不到关联的 session 。

我从来没有使用过SWFUpload,但看起来它没有将jsessionid cookie 与请求一起传递给服务器端,因此服务器端无法识别客户端。谷歌搜索“swfupload jsessionid”还了解到您不是唯一遇到此特定问题的人。要解决此问题,您需要将 jsessionid 附加到设置中的 URL:

upload_url: "upload_pages/uploader.jsp;jsessionid=${pageContext.session.id}",

也就是说,下面一行

post_params: {"PHPSESSID" : ""},

看起来也很可疑。在 JSP/Servlet 环境中空的 PHP session ID 在做什么?你在复制别人的代码时不会忽略/忘记这一点吗?

关于java - Firefox 的 swfupload 中的 UploadError 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2271097/

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