tags:

views:

287

answers:

4

Hello Everybody,

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

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

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

att Sherlack

A: 

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.

Todd Moses
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.
Sherlack
I'm gonna try to do these settings now in .htaccess to see if it works.
Sherlack
Ok, i tried setting up memory_limit , post_max_size,upload_max_filesize in the htaccess file but didnt work.
Sherlack
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
Todd Moses
Did this but still not work.
Sherlack
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.
Todd Moses
Il try this! thanks
Sherlack
+2  A: 

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.

Johannes Gorset
+2  A: 

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.

Pekka
A: 

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!

Sherlack