使用 SWFUpload,为什么我的上传在使用 Firefox 时没有被 upload.aspx 处理(它们在 IE 中可以正确处理)?
使用 SWFUpload v2.2、Firefox 3、IE 8、Flash 10
在我的 ASP.NET 应用程序中,所有上传都由 upload.aspx 处理(我在设置对象中设置了正确的 upload_url)。
谁能告诉我为什么(在 Firefox 中)上传从未到达 upload.aspx 页面?
用户访问上传文件的页面的大部分代码如下所示(注意:正在使用母版页):
<script type="text/javascript" src="../swfupload/swfupload.js"></script>
<script type="text/javascript" src="../js/handlers.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function() {
swfu = new SWFUpload({
// Backend Settings
upload_url: "../upload.aspx",
post_params: {
"ASPSESSID": "<%=Session.SessionID %>"
},
// File Upload Settings
file_size_limit: "10 MB",
file_types: "*.*",
file_types_description: "All Files",
file_upload_limit: 1,
file_queue_limit: 1,
//assume_success_timeout: 60,
// Event Handler Settings - these functions as defined in Handlers.js
// The handlers are not part of SWFUpload but are part of my website and control how
// my website reacts to the SWFUpload events.
file_queue_error_handler: fileQueueError,
file_dialog_complete_handler: fileDialogComplete,
upload_progress_handler: uploadProgress,
upload_error_handler: uploadError,
upload_success_handler: uploadSuccess,
upload_complete_handler: uploadComplete,
// Button settings
button_image_url: "../Images/XPButtonNoText_160x22.png",
button_placeholder_id: "spanButtonPlaceholder",
button_width: 160,
button_height: 22,
button_text: '<span class="button">Upload File<span class="buttonSmall">(10 MB Max)</span></span>',
button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 1,
button_text_left_padding: 5,
// Flash Settings
flash_url: "../swfupload/swfupload.swf", // Relative to this file
custom_settings: {
upload_target: "divFileProgressContainer"
},
// Debug Settings
debug: false
});
}
</script>
Using SWFUpload v2.2, Firefox 3, IE 8, Flash 10
In my ASP.NET application all uploads are being processed by upload.aspx (I have the correct upload_url set in the settings object).
Can anyone tell me why (in Firefox) the uploads never hit the upload.aspx page?
Most of the code for the page that the user visits to upload a file is shown here (note: master pages are being used):
<script type="text/javascript" src="../swfupload/swfupload.js"></script>
<script type="text/javascript" src="../js/handlers.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function() {
swfu = new SWFUpload({
// Backend Settings
upload_url: "../upload.aspx",
post_params: {
"ASPSESSID": "<%=Session.SessionID %>"
},
// File Upload Settings
file_size_limit: "10 MB",
file_types: "*.*",
file_types_description: "All Files",
file_upload_limit: 1,
file_queue_limit: 1,
//assume_success_timeout: 60,
// Event Handler Settings - these functions as defined in Handlers.js
// The handlers are not part of SWFUpload but are part of my website and control how
// my website reacts to the SWFUpload events.
file_queue_error_handler: fileQueueError,
file_dialog_complete_handler: fileDialogComplete,
upload_progress_handler: uploadProgress,
upload_error_handler: uploadError,
upload_success_handler: uploadSuccess,
upload_complete_handler: uploadComplete,
// Button settings
button_image_url: "../Images/XPButtonNoText_160x22.png",
button_placeholder_id: "spanButtonPlaceholder",
button_width: 160,
button_height: 22,
button_text: '<span class="button">Upload File<span class="buttonSmall">(10 MB Max)</span></span>',
button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 1,
button_text_left_padding: 5,
// Flash Settings
flash_url: "../swfupload/swfupload.swf", // Relative to this file
custom_settings: {
upload_target: "divFileProgressContainer"
},
// Debug Settings
debug: false
});
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很有可能,因为这适用于 IE 而不是 Firefox,并且您正在尝试进行一些身份验证(因此 post_params: {
"ASPSESSID": "<%=Session.SessionID %>"
},)
您遇到了 flash/firefox/opera“bug”/问题。在这种情况下,Flash 上传程序实际上在其自己的上下文中运行,而不是在共享上下文中运行,并且无法访问 sessionID 的 cookie。
使用调试器检查正在生成的内容或者是否有错误。
这里的论坛中有几个线程,我认为一些针对 ASP(不是我的专业)的线程提供了一些解决方法。搜索 flash、upload、sessionId 和 ( ASP)
Good chance that since this is working in IE and not in Firefox and you are trying to do some authentication ( hence post_params: {
"ASPSESSID": "<%=Session.SessionID %>"
},)
you are hitting the flash/firefox/opera "bug"/issue. In this case the flash uploader is actually running in its own context and not in the shared context and can not acess the cookies for the sessionID.
Use a debugger to check and see what is being generated or if you have an error there.
There are several threads in the forum here, I think some for ASP ( not my specialty) that give some workarounds. Search for flash, upload, sessionId and ( ASP)
该代码对我来说看起来没问题。
Firefox 控制台是否显示任何错误?
您可以尝试使用相对于 Web 根目录
/xyz/swfupload/upload.aspx
的路径来确保这不是以不同方式解析相对路径的情况吗?您是否 1000% 确定您的 aspx 文件实际上没有被调用?或者可能只是身份验证过程由于某种原因出错了?您可以将日志或邮件命令放入 ASPX 文件的第一行吗?
上传过程本身是否启动并显示进度条?
SWFUpload 带有错误处理程序挂钩。它们都不抛出错误消息吗?
The code looks o.k. to me.
Does the Firefox console show any errors?
Can you try using paths relative to the web root
/xyz/swfupload/upload.aspx
to make sure it's not a case of relative paths being resolved differently?Are you 1000% sure your aspx file is actually not being called? Or could it be that just the authentication process goes wrong for some reason? Can you put a log or mail command into the 1st line of the ASPX file?
Does the upload process itself start and show a progress bar?
SWFUpload comes with error handler hooks. Do none of them throw an error message?