代码之家  ›  专栏  ›  技术社区  ›  Jimmy

上传不在本地主机之外触发事件

  •  0
  • Jimmy  · 技术社区  · 16 年前

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

    http://mycomp1/project/etc

    有什么想法吗?

    我的上传代码:

    $('#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 回复  |  直到 16 年前
        1
  •  3
  •   Kevin Peno    16 年前

    SWF Upload post_params 设置。然后,请确保在会话开始之前执行以下操作:

    if( isset( $_POST['session_id'] ) && !empty( $_POST['session_id'] ) )
        session_id( $_POST['session_id'] )
    
    session_start();
    

    http://swfupload.org/forum/generaldiscussion/98

    http://www.uploadify.com/forum/viewtopic.php?f=7&t=1178

    Using Flash with ASP.NET MVC and Authentication

        2
  •  1
  •   mth    16 年前

    crossdomain.xml 到Uploadify正在访问的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>   
    

    此外,我建议你阅读 this manual 为了更好地理解这个文件的全部内容。

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