Created
February 27, 2015 17:34
-
-
Save melloc01/c6316fe03956f1984014 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Setter for text | |
* | |
* @param mixed $text Value to set | |
* | |
* @return self | |
*/ | |
public function setText($text) | |
{ | |
$upload_path = '../public/modules/blog/posts/img/'; | |
$usr_upload_path = '/modules/blog/posts/img/'; | |
$aux = explode('"data:image/png;base64,', $text); | |
$size = sizeof($aux); | |
$post = []; | |
$post = $aux[0]; | |
for ($i=1; $i < $size; $i++) { | |
$aux_1 = explode('"', $aux[$i]); | |
//aux_1 é a string base64 | |
$upload_name = md5( mt_rand().mt_rand().mt_rand().'post').'.png'; | |
$file_location = $upload_path.$upload_name; | |
$usr_file_location = $usr_upload_path.$upload_name; | |
$base64_code = array_shift($aux_1); | |
$post.= '"'.$usr_file_location.'"'; | |
if ($aux_1) | |
foreach ($aux_1 as $key => $text_piece) | |
$post .= $text_piece; | |
$this->base64_to_jpeg($base64_code,$file_location); | |
} | |
$this->text = $post; | |
return $this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment