note 117426 added to function.base64-decode
| From: | kennethtang4 at hotmail dot com | Date: | Tue, 09 Jun 2015 15:54:07 +0000 |
| Subject: | note 117426 added to function.base64-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202786@lists.php.net to get a copy of this message | ||
This is a note for any one who encounter problems using POST in html and javascript with base64
encoding to transfer large quantity of data.
base64_decode deals pretty well with POST for small quantity of data but when large quantity of data
is transfered, the data decoded is corrupted. I found out that it is because base64 encode will use
'+' to encode data and POST will treat that as spacebar.
The solution I have come up with is to replace the spacebar with '+' before using
base64_decode. For any one who is interested, this is the function I used.
<?php
function replace_space($e)
{
for ($i=0;$i<strlen($e);$i++)
{
if (ord(substr($e, $i, 1)) == 32)
{
$e[$i] = '+';
}
}
return $e;
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 1.36.254.204
----
Manual Page -- http://php.net/manual/en/function.base64-decode.php
Edit -- https://master.php.net/note/edit/117426
Del: integrated -- https://master.php.net/note/delete/117426/integrated
Del: useless -- https://master.php.net/note/delete/117426/useless
Del: bad code -- https://master.php.net/note/delete/117426/bad+code
Del: spam -- https://master.php.net/note/delete/117426/spam
Del: non-english -- https://master.php.net/note/delete/117426/non-english
Del: in docs -- https://master.php.net/note/delete/117426/in+docs
Del: other reasons-- https://master.php.net/note/delete/117426
Reject -- https://master.php.net/note/reject/117426
Search -- https://master.php.net/manage/user-notes.php