Firefox 的 swfupload 中的 UploadError 403
我正在尝试使用 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。
I'm trying to upload files using swfuploder and it works fine in IE.But its getting "UploadError 403" in Firefox. I'm using apache-tomcat-6.0.16 and couldnt access the .htaccess
file as well.
This is my code to use for 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>
I have tried with both absolute and relative url for "upload_url" but the same error "uploadError 403" appears.But it works for IE.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
HTTP 状态代码 403 表示禁止。这是一个身份验证错误。该请求需要经过身份验证的用户(登录用户),但该用户不在会话中,或者找不到关联的会话。
我从来没有使用过SWFUpload,但看起来它没有将
jsessionid
cookie随请求一起传递到服务器端,从而导致服务器端无法识别客户端。谷歌搜索“swfupload jsessionid”也会发现您并不是唯一遇到此问题的人特别的问题。要解决此问题,您需要将jsessionid
附加到设置中的 URL:也就是说,以下行
看起来也很可疑。在 JSP/Servlet 环境中,空的 PHP 会话 ID 有何作用?您在复制粘贴别人的代码时是否忽略/忘记了这一点?
HTTP status code 403 means Forbidden. This is an authentication error. The request requires an authenticated user (logged-in user), but either the user isn't there in the session, or the associated session cannot be found.
I have never used SWFUpload, but it look like that it didn't pass the
jsessionid
cookie along with the request to the server side, so that the server side cannot identify the client. Googling "swfupload jsessionid" also learns that you're not the only one who encountered this particular problem. To fix this, you need to append thejsessionid
to the URL in the settings:That said, the following line
looks suspicious as well. What is an empty PHP session ID doing there in a JSP/Servlet environment? Aren't you overlooking/forgotting this while copypasting someone else's code?
我也有类似的问题,但是是在 apache/PHP 中。所以我在这里链接了一个可能的解决方案。
从我到目前为止发现的情况来看,这似乎是安装了安全扩展(即会话保护/加密)的服务器上的会话身份验证的安全问题,这使得服务器认为 html 页面和 swf 上传者是不同的用户从而导致403错误。 http://imagevuex.com/forum/viewtopic.php?f=27& ;t=4337
另外检查 mod_security 是否已禁用并尝试添加这些 .htaccess 设置,它似乎对某些人有效。
另一个解决方案似乎是(也是.htaccess),来自 http://www.ramirezcobos.com/2010/01/05/swfupload_0_0-error-http-status-403-solved/
最后,firefox 可能是在这里发现的 cookie bug http://topecoders.blogspot.com/2010/06/solution-for-flash- cookie-bug.html
Im having a similar problem but in apache/PHP. So im linking a possible solution here.
From what i've found so far it seems to be a security issue with the session authentication on the server in which you have security extensions installed (ie session protection/encryption) which makes the server think that html page and swf uploader are different users thus causing the 403 error. http://imagevuex.com/forum/viewtopic.php?f=27&t=4337
Also check that mod_security is disabled and try adding these .htaccess settings, it seems to work for some.
Another solution seems to be (also .htaccess), from http://www.ramirezcobos.com/2010/01/05/swfupload_0_0-error-http-status-403-solved/
Finally firefox might be a cookie bug found here http://topecoders.blogspot.com/2010/06/solution-for-flash-cookie-bug.html