0

我有一个非常直接的上传页面,允许用户上传文件,当我在通过http://localhost/project/etc访问它的本地机器上运行它时,它运行良好

问题是当我尝试从本地主机外部访问相同的东西时,即使尝试通过我的机器名(http://mycomp1/project/etc)访问它,页面加载/等并且一切似乎都可以工作,但是没有任何东西被转移,我打开了萤火虫,通常它会显示任何正在通过的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 设置有关,但即使设置为 always,如 uploadify 网站上所说,它仍然没有触发任何后端脚本或我的 onComplete 函数

更新2:在进一步检查时,在非本地主机设置中,我的脚本路径似乎不正确,但现在脚本位于正确的位置,我在 onComplete 函数中得到的响应等于我的登录页面的 html 输出。有任何想法吗?

UPDATE3:看起来我的脚本路径没问题,只是由于某种原因,当不在本地主机上时,我得到了登录页面的响应,而不是像我应该从后端代码那样上传成功或上传失败

4

2 回答 2

3

对于登录页面问题,听起来 Flash 不尊重您的会话。

假设您使用的是 PHP,请确保您在帖子中从您的 Flash 对象传递您的 PHP sessionid。例如,对于SWF 上传,这是通过将其传递到post_params设置来完成的。然后,确保在会话开始之前执行以下操作:

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

这看起来很有希望:::

将 Flash 与 ASP.NET MVC 和身份验证结合使用

于 2009-11-02T20:08:15.610 回答
1

有〜同样的问题,解决方案非常简单 - 添加 crossdomain.xml到您正在访问的 Web 服务器的可见根文件夹中。它应该包含以下信息

<?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>   

此外,我建议您阅读本手册以更好地理解该文件的全部内容。

请尝试此方法,看看这是否是问题的根源。

于 2009-11-06T14:10:00.937 回答