简体   繁体   中英

Apache - 406 Not Acceptable PHP Problem

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

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.

除了其他答案(可能是post_max_size,因此是我对图像大小的问题)之外, 此博客条目还概述了406与Flash文件上传结合使用的更为罕见的原因,这显然是由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.

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM