tags:

views:

35

answers:

3

Hi. I'm try to post in a hidden input a base64 encoded image (~ 500KB) and all I get is an error

   501 Method Not Implemented

GET to /test.php not supported.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

my code

<?php error_reporting(E_ALL) ?>
<html>
<head></head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<input type="hidden" name="image" value="{base64 encoded image}">
<input type="submit" name="" value="OK">
</form>

<?php if($_POST) {
    echo '<pre>'.print_r($_POST, true).'</pre>';
} ?>

</body>
</html>

Ps. on localhost everything works fine.

Thanks for help.

A: 

Assuming you're using the same browser it may be the post_max_size php.ini setting, although I would think it would be set much higher than ~500KB by default.

adam
ini_get('post_max_size') returns 64M
kat
A: 

This is probably due to security issues. Try this:

To fix this, add this to your /etc/httpd/conf/httpd.conf, inside the block that starts with (the path of the root of your Apache directory tree):

SecRuleEngine off

<Directory "/var/www/html">
    SecRuleEngine off
</Directory>

/var/www/html is the DOCUMENT_ROOT of your site. Restart/reload apache.

hopeseekr
A: 

Looking at the error message, there are two issues. One is a 501, one is a 404.

The 501 is because your web server isn't recognising the POST method. Try it with post in lowercase (although i'd be surprised if that caused an error).

The 404 is because the target of the form isn't being found (or it might be misconfigured) and there is no ErrorDocument set up to handle 404's. Have a look at the html of the form in your browser and make sure that $_SERVER['PHP_SELF'] is outputting the correct URI.

If neither of these seem odd, try posting the form without any image data. It might be that you need to encode the data for POST transport.

adam