介绍
我正在尝试在潜在的复杂环境中实现相对简单的目标。我想使用Netvibes UWA format将文件从JavaScript小部件(plupload jQuery UI plugin)上传到本地Intranet服务器。
问题
我似乎已经正确设置了我的代码-出现plupload
容器,我可以很高兴地选择和上传文件。上载似乎有效-每个文件命中率100%-但是当我检查Firebug控制台时,出现以下错误:OPTIONS upload.php - 403 Forbidden
而且文件不会上传到我指定的files
目录中。
环境
frogserver.curriculum.local
staff.curriculum.local
代码
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;
});
}
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>
PHP
我正在使用的PHP脚本是捆绑的
upload.php
文件处理脚本,其顶部还添加了以下代码:// * - stands for all domains
header("Access-Control-Allow-Origin: *");
我还更改了上传目录目标:
// Settings
//$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
$targetDir = 'files';
思想
Access-Control-Allow-Origin
header 编辑:IIS权限
刚刚检查,一切似乎正确:
最佳答案
[编辑] CORS
权限似乎还不错,这可能是CORS问题。
我偶然发现monsur对此问题的回答:Is it possible to use XMLHttpRequest across Domains,并引述:
权限
根据此doc:
您可能正在检查错误用户的权限( IUSR_ASHVOIP ),尝试 IIS_WPG (似乎适合您)或 IIS_IUSRS ,具体取决于您的配置。