2

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

3
  • Can you show a typical image that will fail? How large is it? Commented Feb 18, 2010 at 20:00
  • the images size are about 50kb - 100kb in jpg format. Commented Feb 18, 2010 at 20:40
  • I'm trying the solutions below to try them out. Will keep in touch. thanks again guys! Commented Feb 18, 2010 at 20:43

5 Answers 5

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

0

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.

5 Comments

I check these values and they configure as follow: memory_limit = 32M, post_max_size = 8M, upload_max_filesize = 8M, But still doesnt work and the upload returns the 406 status code.
I'm gonna try to do these settings now in .htaccess to see if it works.
Ok, i tried setting up memory_limit , post_max_size,upload_max_filesize in the htaccess file but didnt work.
You have to do it in your PHP.ini file too. Plus is your post and upload_max_size over 8mb. Change your PHP.ini file with a higher value
Copy the PHP.ini and Apache config values from your test server (test it) - if it works then change each value (one at a time) to what they need to be in production to find the problem.
0

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!

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.