Skip to content

Instantly share code, notes, and snippets.

@rogeriotaques
Last active November 26, 2019 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogeriotaques/e39ad9303f0e84929c8a498455cba4ab to your computer and use it in GitHub Desktop.
Save rogeriotaques/e39ad9303f0e84929c8a498455cba4ab to your computer and use it in GitHub Desktop.
<?php
public function uploadFileFromBlobString($base64string = '', $file_name = '', $folder = '')
{
$file_path = "";
$result = 0;
// Convert blob (base64 string) back to PDF
if (!empty($base64string)) {
$base64data = base64_decode($base64string, true);
$file_path = "{$folder}/{$file_name}";
// Return the number of bytes saved, or false on failure
$result = file_put_contents("{$this->_assets_path}/{$file_path}", $base64data);
}
return $result;
} // uploadFileFromBlobString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment