Created
July 12, 2015 09:51
-
-
Save RoesWibowo/94b2d1cf941b06c101ef to your computer and use it in GitHub Desktop.
Save base64 encoded files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param $fileString | |
* @param $location | |
* @param $filename | |
* @return array | |
*/ | |
function saveFile($fileString, $location, $filename) { | |
$result = []; | |
$split = explode(';', $fileString); | |
if (count($split)) { | |
$hash = explode(',', $split[1]); | |
if(count($hash)) { | |
$filename2 = date('YmdHis').'_'.$filename; | |
file_put_contents($location.'/'.$filename2, base64_decode($hash[1])); | |
$result = [ | |
'filename' => $filename, | |
'uploaded' => $filename2 | |
]; | |
} | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment