Created
May 14, 2013 20:09
-
-
Save gustavo-rodrigues-dev/5579073 to your computer and use it in GitHub Desktop.
Método que retorna o source da imagem e exibe na view sem renderizar ou salvar o arquivo.
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
//dataImage | |
$file = $_FILES['image']; | |
$image = dataImage($file); | |
echo '<img src="'.$image.'" />'; |
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
/** Return source image | |
* @param array $file | |
* @return string Image | |
*/ | |
public function dataImage($file){ | |
$contents = file_get_contents($file['tmp_name']); | |
$base64 = base64_encode($contents); | |
return ('data:' . $file['type'] . ';base64,' . $base64); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment