note 117426 deleted from function.base64-decode by cmb
| From: | cmb@php.net | Date: | Tue, 09 Jun 2015 16:57:53 +0000 |
| Subject: | note 117426 deleted from function.base64-decode by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-202789@lists.php.net to get a copy of this message | ||
Note Submitter: kennethtang4 at hotmail dot com
----
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;
}
?>