簡體   English   中英

發布base64編碼文件問題

[英]Posting a base64 encoded file problem

我試圖在隱藏的輸入中發布一個base64編碼的圖像(~500KB),我得到的只是一個錯誤

   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.

我的代碼

<?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。 在localhost一切正常。

感謝幫助。

假設你使用相同的瀏覽器,它可能是post_max_size php.ini設置,雖然我認為它默認設置遠高於~500KB。

這可能是由於安全問題。 嘗試這個:

要解決此問題,請將其添加到/etc/httpd/conf/httpd.conf中,該塊位於以(Apache目錄樹的根目錄路徑)開頭的塊內:

SecRuleEngine off

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

/ var / www / html是您網站的DOCUMENT_ROOT。 重啟/重新加載apache。

查看錯誤消息,有兩個問題。 一個是501,一個是404。

501是因為您的Web服務器無法識別POST方法。 嘗試使用小寫的帖子(雖然如果這導致錯誤我會感到驚訝)。

404是因為沒有找到表單的目標(或者可能是配置錯誤)並且沒有設置ErrorDocument來處理404。 在瀏覽器中查看表單的html並確保$_SERVER['PHP_SELF']輸出正確的URI。

如果這些都不奇怪,請嘗試發布沒有任何圖像數據的表單。 可能需要對POST傳輸的數據進行編碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM