valums Ajax file uploader+406 not acceptable Error In Firbug
I am using Valums Ajax Uploader on my website. Everything is working fine on my local computer but when i try the same uploader on my website main server then Firbug shows this error:
POST http://www.myexampledomain.com/upload.php?qqfile=201004151821387.1.flv 406 Not Acceptable 8.37s fileuploader.js (line 1204)
Response Body
<title开发者_Go百科>406 Not Acceptable</title>
<p>An appropriate representation of the requested resource /upload.php could not be found on this server.</p>
<p>Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.</p>
All Request & Response header are here and in fileuploader.js
file code near to line no 1204 is:
params = params || {};
params['qqfile'] = name;
var queryString = qq.obj2url(params, this._options.action);
xhr.open("POST", queryString, true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
xhr.setRequestHeader("Content-Type", "application/octet-stream");
xhr.send(file); //line 1204
I have already searched on Google and this website but nothing useful is found so please tell me how can i solve this problem?
My other question regarding this problem - 406 error on firebug only
The problem is in mod_security.
Probably, you have the rule to block all file upload requests if their content encoding is different from form (not multipart/form-data or form-urlencoded).
First - you can comment that line in your apache config file.
Second (and more convinient regarding valums uploader) - add encoding: 'multipart' options to your fileuploader - that will add multipart/form-data for Content-Encoding so apache will allow that request.
I am having the same issue, and i resolved it by disabling mod_security in .htaccess file
<IfModule mod_security.c>
# Turn off mod_security filtering.
SecFilterEngine Off
# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off
</IfModule>
Please use above at your own risk, as disabling mod_security can anticipate some security hole server side.
I think mod_security
is getting in the way. It seem that one (only?) way to solve this is to disable POST scanning by adding to your .htaccess
the following:
<ifmodule mod_security.c>
SecFilterScanPOST Off
</ifmodule>
I would try to add an .htaccess
to the root directory of your application and hope it works as hosting provider may not allow user specific .htaccess
files.
Relevant article - http://tech.shantanugoel.com/2008/05/01/http-406-errors-galore.html
I am not sure if this will help solve your problem, but I recently came across this same issue with POST'ing using JQuery $.ajax. I also had a similar problem using JQuery Qaptcha which also uses a bit of ajax and a POST.
On both occasion I was able to change the POST to a GET (including in the php files that were being called) and it would then work on my host's live server.
I have yet to fully understand the good or the bad of doing this as I am pretty inexperienced in this area, so if someone has any thoughts as to whether this is a bad thing to do, then input would be appreciated.
Example:
if($cust_acceptance == 'yes') {
$.ajax({
type: "GET", //Swapped out a POST for a GET.
url: "/scripts/php/update_shortlist.php",
data: "action=add&shortlist_id="+shortlist_id+"&rb_ref="+rb_ref,
success: function(msg){
//alert ("success: "+rb_ref);
I think the other people are correct that it is permission issues with mod_security, but you are unlikely to be able to convince your hosting company to change these settings for you - if you are using a shared service. Obviously if you are on a VPS or dedicated server you can make the changes needed yourself.
Hope that helps.
精彩评论