我正在使用Valums文件上传器(https://github.com/Valums-File-Uploader/file-uploader)将文件上传到服务器。当我尝试上传文件时,它上传100%,然后我得到403 Forbidden响应。
当我访问处理上传的php脚本以及脚本执行Post请求时,它正常加载,我没有收到403 Forbidden错误消息。
这个403错误的原因可能仅在发布请求时发生,而不是通常的浏览器访问?我在两个不同的服务器设置上尝试了这个脚本,它就像一个魅力一样,但不能让它在另一个上工作。
将文件上传器附加到div的脚本:
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader'),
action: 'fileuploader/file_upload.php<?php if ( isset( $_GET['maxwidth'] ) ) echo "?maxwidth=" . $_GET['maxwidth']; ?>',
params: { },
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
sizeLimit: 2097152,
uploadButtonText: '<?php echo t('Upload image'); ?>',
cancelButtonText: '<?php echo t('Cancel'); ?>',
dragText: '<?php echo t('Drop files here to upload'); ?>',
failUploadText: '<?php echo t('Upload unsuccessful'); ?>',
onComplete: function(id, fileName, responseJSON){
$( '#cancel-upload' ).trigger( 'click' );
$( '#refresh' ).trigger( 'click' );
selectFile = responseJSON['file'];
}
});
file_upload.php
脚本是稍微修改过的脚本,附带脚本:https://github.com/Valums-File-Uploader/file-uploader/blob/master/server/php.php
这是我收到的回复:
Request URL:http://***/mod/ckeditor/plugins/scriptemimage/php/fileuploader/file_upload.php?phpsessid=vej2rc55iajknkjsp4taecsbn2&maxwidth=600&qqfile=751152_13643298+(Custom).jpg
Request Method:POST
Status Code:403 Forbidden
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:hr,en-US;q=0.8,en;q=0.6
AlexaToolbar-ALX_NS_PH:AlexaToolbar/alxg-3.2
Connection:keep-alive
Content-Length:9774
Content-Type:image/jpeg
Cookie:__utma=***; __utmc=***; __utmz=***; PHPSESSID=***
Host:www.***.***
Origin:http://www.***.***
Referer:http://***/mod/ckeditor/plugins/scriptemimage/php/browser.php?langCode=hr&maxwidth=600&run=window.opener.document.getElementById('new-article-image').value=selectedImages();window.opener.updateThumb();
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
X-File-Name:751152_13643298%20(Custom).jpg
X-Mime-Type:image/jpeg
X-Requested-With:XMLHttpRequest
Query String Parametersview sourceview URL encoded
phpsessid:vej2rc55iajknkjsp4taecsbn2
maxwidth:600
qqfile:751152_13643298 (Custom).jpg
Response Headersview source
Connection:close
Content-Length:399
Content-Type:text/html; charset=iso-8859-1
Date:Sat, 28 Dec 2013 18:39:20 GMT
Server:Apache
答案 0 :(得分:0)
这可能是您的浏览器有cookie在服务器上验证它,但邮件请求没有。检查浏览器的cookie以获取上传网站。