plupload运行时在尝试访问upload.php时返回403 FORBIDDEN错误

dun*_*unc 7 javascript php iis jquery plupload

介绍

我想在一个潜在的复杂环境中实现相对简单的事情.我想使用plupload jQuery UI插件将文件从JavaScript小部件(Netvibes UWA格式)上传到本地Intranet服务器.

问题

我似乎正确地设置了我的代码 - plupload容器出现了,我可以愉快地选择和上传文件.上传似乎工作 - 每个文件达到100% - 但当我检查我的Firebug控制台时,我收到以下错误:

OPTIONS upload.php - 403 Forbidden

并且文件不会上传到我指定的files目录.

Firebug Net输出

环境

  • 源服务器frogserver.curriculum.local位于内部IP 192.168.3.15上
  • 收件人服务器staff.curriculum.local位于内部IP 192.168.3.60上
  • 原始服务器是Linux,但我必须HTML/JS/PHP/SQL不能直接访问,一切都必须通过上述Netvibes的通用的Widget API来完成.它是由www.frogtrade.com提供的封闭式虚拟学习环境解决方案
  • 收件人服务器是Windows/IIS

JavaScript的

widget.onLoad = function(){
    $( "#datetime" ).datepicker({ dateFormat: "yy-mm-dd" });
    Input.init();

    /* plupload */
    $("#uploader").plupload({
        // General settings
        runtimes : 'html5,flash,html4',
        url : 'http://staff.curriculum.local/frog/LOTS/upload.php',
        max_file_size : '1000mb',
        max_file_count: 20, // user can add no more then 20 files at a time
        chunk_size : '1mb',
        rename: true,
        multiple_queues : true,

        // Resize images on clientside if we can
        resize : {width : 320, height : 240, quality : 90},

        // Rename files by clicking on their titles
        rename: true,

        // Sort files
        sortable: true,

        // Specify what files to browse for
        filters : [
            {title : "Image files", extensions : "jpg,gif,png"},
            {title : "Zip files", extensions : "zip,avi"}
        ],

        // Flash settings
        flash_swf_url : '/user/74/186718.swf'
    });

    // Client side form validation
    $('form').submit(function(e) {
        var uploader = $('#uploader').plupload('getUploader');

        // Files in queue upload them first
        if (uploader.files.length > 0) {
            // When all files are uploaded submit form
            uploader.bind('StateChanged', function() {
                if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
                    $('form')[0].submit();
                }
            });

            uploader.start();
        } else
            alert('You must at least upload one file.');

        return false;
    });
}
Run Code Online (Sandbox Code Playgroud)

HTML

<form  method="post" action="../dump.php">
    <div id="uploader">
        <p>Your browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

PHP

我正在使用的PHP脚本是捆绑的upload.php文件处理脚本,在顶部添加了此代码:

// * - stands for all domains
header("Access-Control-Allow-Origin: *");
Run Code Online (Sandbox Code Playgroud)

我还更改了上传目录的目标:

// Settings
//$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
$targetDir = 'files';
Run Code Online (Sandbox Code Playgroud)

思考

  • 我不确定这是否被归类为"跨域"文件传输?我试图将其设置为好像,因此Access-Control-Allow-Origin我的PHP脚本中的标题
  • Netvibes UWA和VLE设置可能会以某种方式阻碍
  • Internet Guest帐户的LOTS文件夹上的IIS权限似乎是正确的(即"读取"权限),但我不完全确定; 它在"特殊权限"上有"拒绝",我似乎无法看到这些权限是什么,或改变它

编辑:IIS权限

刚检查,一切似乎都正确:

权限

Big*_*ood 1

[编辑] CORS

由于权限看起来没问题,这可能是 CORS 问题。

我偶然发现了monsur对这个问题的回答: Is it possible to use XMLHttpRequest across Domains,引用:

COR 请求实际上由两个物理 HTTP 请求组成:1) 预检请求,2) 实际请求。您上面发布的请求看起来像预检请求,因为它使用 HTTP OPTIONS 方法。因此,您要做的第一件事是验证您的服务器是否接受 OPTIONS 请求(我相信这应该可行,但它可以解释为什么您会收到 403)。

权限

根据这个文档

为上传的内容创建一个单独的文件夹,并更改上传文件夹的 NTFS 文件权限

通过这样做,您可以配置与 Web 应用程序的其余部分不同的上传内容的行为。授予 IIS 工作进程标识的上传文件夹读取和写入权限。对于Windows Server 2003 中的IIS 6.0 ,您可以使用IIS_WPG用户组来执行此操作。对于IIS 7.0及更高版本,您可以使用IIS_IUSRS用户组。

您可能正在检查错误用户的权限(IUSR_ASHVOIP),请尝试IIS_WPG(似乎适合您)或IIS_IUSRS,具体取决于您的配置。