我正在尝试使用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”但出现相同的错误“uploadError 403”。但它适用于IE。
答案 0 :(得分:1)
HTTP状态代码403表示Forbidden。这是一个身份验证错误。该请求需要经过身份验证的用户(登录用户),但会话中的用户不在,或者找不到关联的会话。
我从未使用过SWFUpload,但看起来它没有将jsessionid
cookie连同请求一起传递给服务器端,因此服务器端无法识别客户端。谷歌搜索“swfupload jsessionid”也知道你不是唯一遇到这个特殊问题的人。要解决此问题,您需要在设置中将jsessionid
附加到网址:
upload_url: "upload_pages/uploader.jsp;jsessionid=${pageContext.session.id}",
那说,以下一行
post_params: {"PHPSESSID" : ""},
看起来也很可疑。什么是在JSP / Servlet环境中执行的空PHP会话ID?你是否在复制其他人的代码时忽略/忘记了这一点?
答案 1 :(得分:1)
我有一个类似的问题,但在apache / PHP中。所以我在这里链接一个可能的解决方案。
从我发现到目前为止,安装了安全扩展的服务器上的会话身份验证(即会话保护/加密)似乎是安全问题,这使得服务器认为html页面和swf上传器是不同的用户因此导致403错误。 http://imagevuex.com/forum/viewtopic.php?f=27&t=4337
同时检查mod_security是否已禁用并尝试添加这些.htaccess设置,它似乎适用于某些人。
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
另一个解决方案似乎是(也是.htaccess),来自http://www.ramirezcobos.com/2010/01/05/swfupload_0_0-error-http-status-403-solved/
SetEnvIfNoCase Content-Type “^multipart/form-data;” “MODSEC_NOPOSTBUFFERING=Do not buffer file uploads”
最后,firefox可能是http://topecoders.blogspot.com/2010/06/solution-for-flash-cookie-bug.html
中发现的cookie错误