Want more features on Pastebin? Sign Up, it's FREE!
Guest

upload

By: a guest on Dec 17th, 2011  |  syntax: PHP  |  size: 0.42 KB  |  views: 377  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. function upload($tmp, $nome, $largura, $pasta){
  3.   $foto = imagecreatefromjpeg($tmp);
  4.   $x = imagesx($foto);
  5.   $y = imagesy($foto);
  6.   $altura = ($largura * $y) / $x;
  7.                
  8.   $novaimg = imagecreatetruecolor($largura, $altura);
  9.   imagecopyresampled($novaimg, $foto, 0,0,0,0,$largura, $altura, $x, $y);
  10.   imagejpeg($novaimg, "$pasta/$nome");
  11.   imagedestroy($novaimg);
  12.   imagedestroy($foto);
  13.   return ($nome);
  14. }
  15. ?>
clone this paste RAW Paste Data