Apache - 406不可接受的PHP问题

I'm debugging a flash website that do a request to an php file named upload.php to upload some images to the server.

The problem i'm having that debugging it with Firebug the request to that page is throwing a 406 Not Acceptable status code and is not saving the images.

Post Data:

alt text http://pixelstg.com/rum_post_info.JPG

This website runs well on the staging server but in production server this process of the image upload fails. I only can assume that a change to apache configuration / php must be done, but i have no idea what to do.

upload.php code:

alt text http://pixelstg.com/rum_upload_code.JPG

Any help or guidance will be welcome, thanks in advance for the help.

att Sherlack

The problem was with the Suhosin PHP hardening module. Some of the variable value length limits were being exceeded. The file that was edited was /etc/php.d/suhosin.ini and it logs to /var/log/.

After the file was edited by my hosting administrator the problem was resolved.

Thanks all for your support!

This is most likely a problem with your post_max_size.

In php.ini change the following to a number that matches your need:

memory_limit = 0M
post_max_size = 0M
upload_max_filesize = 0M

If this does not work then you will need to do a similar change in your .htaccess file in Apache.

A 406 Not Acceptable error means the server wants to send a response which type is not listed in the accept headers sent by the client (in this case, Flash); it is unrelated to your files failing to upload.

Your code looks fine, so this might be an issue with your PHP configuration. Make sure upload_max_filesize and post_max_size is configured adequately in your php.ini file.

In addition to the other answers (post_max_size it probably is, hence my question for the image size), this blog entry outlines a more uncommon reason for a 406 in conjuction with a Flash file upload, apparently caused by mod_security.

In my case, just needed to change headers(as Johannes Gorset said) to:

"Accept":"text/html"

Disabling mod_security was not an option.

I was sending a multi-part/form and receiving this annoying error. Changing "Accept header" solved my issue.