Created
February 14, 2020 00:19
-
-
Save helisoncruz/11eb67b634039da77d243afd0cff60a5 to your computer and use it in GitHub Desktop.
Upload de Arquivos Simples
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
<?php | |
function upload_jpg($tmp,$novo_nome,$largura,$pasta){ | |
$img = imagecreatefromjpeg($tmp); | |
$x = imagesx($img); | |
$y = imagesy($img); | |
$altura = ($largura*$y) / $x; | |
$nova_imagem = imagecreatetruecolor($largura,$altura); | |
imagecopyresampled($nova_imagem,$img,0,0,0,0,$largura,$altura,$x,$y); | |
imagejpeg($nova_imagem,"$pasta/$novo_nome",100); | |
imagedestroy($nova_imagem); | |
imagedestroy($img); | |
return($novo_nome); | |
} | |
function upload_png($tmp,$novo_nome,$largura,$pasta){ | |
$img = imagecreatefrompng($tmp); | |
$x = imagesx($img); | |
$y = imagesy($img); | |
$altura = ($largura*$y) / $x; | |
$nova_imagem = imagecreatetruecolor($largura,$altura); | |
imagecopyresampled($nova_imagem,$img,0,0,0,0,$largura,$altura,$x,$y); | |
imagejpeg($nova_imagem,"$pasta/$novo_nome",100); | |
imagedestroy($nova_imagem); | |
imagedestroy($img); | |
return($novo_nome); | |
} | |
function upload_gif($tmp,$novo_nome,$largura,$pasta){ | |
$img = imagecreatefromgif($tmp); | |
$x = imagesx($img); | |
$y = imagesy($img); | |
$altura = ($largura*$y) / $x; | |
$nova_imagem = imagecreatetruecolor($largura,$altura); | |
imagecopyresampled($nova_imagem,$img,0,0,0,0,$largura,$altura,$x,$y); | |
imagejpeg($nova_imagem,"$pasta/$novo_nome",100); | |
imagedestroy($nova_imagem); | |
imagedestroy($img); | |
return($novo_nome); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment