I need to decode a base64 encoded string.
I need to do it with PHP.
The base64_decode()
does not do the job.
I tried with:
base64_decode(strtr($data, '-_,', '+/='));
...it only works sometimes.
The same happens with:
base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
I really do not know how to approach this.
UPDATE:
The data comes from an attached file via GMAIL API.
I save it into the DB, utf8mb4 TEXT field.
I do mysqli -> real_escape_string()
before inserting.
Then I extract it from the DB as $data.