Uploadify 不会在本地主机之外触发事件
-
22-07-2019 - |
题
我有一个非常直接的上传页面,允许用户上传文件,当我在本地计算机上运行它并通过访问它时,它工作得很好 http://localhost/项目/等
问题是当我尝试从本地主机外部访问相同的内容时,即使尝试通过我的机器名访问它(http://mycomp1/project/etc),页面加载/等,一切似乎都正常工作,但没有任何内容被传输,我打开了 firebug,通常它会显示正在执行的任何 ajax 请求,但我什么也没得到。
有任何想法吗?
我的上传代码:
$('#uploadify').uploadify({
'scriptAccess': 'always',
'uploader': '../../scripts/uploadify.swf', //flash source for handling the uploads and size checking
'cancelImg': '../../content/images/cancel.png', //cool cancel button
'script': '../../' + $('#Controller').val() + '/FileSave/' + $('#OrderID').val(), //sends files to the controller with apropriate data
'folder': 'Uploads', //sets the upload directory, not sure if this matters as the files are sent to the controller
'multi': true, //allows multiple uploads
'auto': false, //uploads dont start automatically
'queueSizeLimit': 5, //5 files can be in the queue at a time
'queueID': 'fileQueue', //div to contain the queue of files
'displayData': 'speed', //shows the transfer speed
'fileExt': '*.pdf', //limits to pdfs
'fileDesc': 'PDF', //shows a description in the browse window of filetypes
'sizeLimit': '5242880', //5mb limit
'scriptData': { 'CategoryID': $('#fileCategory').val() }, //passes the selected value of the category drop down
onComplete: function(event, queueID, fileObj, response, data) {//once a transfer completes fires an ajax function to pull in the files for the order
if (response == "Upload Successful") {//if response is successfull, updates div displaying files with new files
GetFiles($('#Controller').val());
}
}
});
更新:这似乎与 scriptAccess 设置有关,但即使设置为始终,如 uploadify 网站上所述,它仍然不会触发任何后端脚本或我的 onComplete 函数
更新2:经过进一步检查,在非本地主机设置中,我的脚本路径似乎不正确,但现在脚本位于正确的位置,我在 onComplete 函数中得到的响应等于我的登录页面的 html 输出。有任何想法吗?
更新3:看起来我的脚本路径没问题,只是由于某种原因,当不在本地主机上时,我得到登录页面的响应,而不是像我应该从后端代码那样上传成功或上传失败
解决方案
对于登录页面问题,听起来 Flash 不尊重您的会话。
假设您使用的是 PHP,请确保在帖子中从 Flash 对象传递 PHP sessionid。例如,与 SWF 上传 这是通过将其传递到 后参数 设置。然后,确保在会话开始之前执行以下操作:
if( isset( $_POST['session_id'] ) && !empty( $_POST['session_id'] ) )
session_id( $_POST['session_id'] )
session_start();
编辑:我刚刚注意到上面有 ASP 标签。我发现这篇关于 ASP 中的 Flash 会话的文章。希望这会有所帮助。
http://swfupload.org/forum/generaldiscussion/98
编辑:更多一些 uploadify + ASP 的具体信息。
http://www.uploadify.com/forum/viewtopic.php?f=7&t=1178
这看起来真的很有希望:::
其他提示
了〜同样的问题和解决方案是相当微不足道的 - 添加crossdomain.xml
到Web服务器(一个或多个)Uploadify正在访问的可见根文件夹。
它应包含以下信息
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="yourdomain"/>
</cross-domain-policy>
此外,我建议你阅读本手册,以更好地了解整点此文件的
请尝试这种方法,看看是否这是一个问题的根源。