Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/04/2009, 05:55
3dweb
 
Fecha de Ingreso: abril-2009
Mensajes: 24
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: Peso de Imagenes

hola samyb8, puedes solventar ese problema utilizando este codigo
Código PHP:
$fileName $_FILES['imageFile']['name'];
$tmpName  $_FILES['imageFile']['tmp_name'];
$fileSize $_FILES['imageFile']['size'];
$fileType $_FILES['imageFile']['type'];


if (
$fileName)
                                   {
                                         
$fp      fopen($tmpName'r+');
                                         
$content fread($fpfilesize($tmpName)); //reads $fp, to end of file length
                                         
                                         
fclose($fp);
                                         
// get originalsize of image
                                         
$im imagecreatefromstring($content);
                                         
$width imagesx($im);
                                         
$height imagesy($im);            
                                                                 
                                         
// Set thumbnail-height to 180 pixels                                    
                                         
$imgh 180;                                          
                                         
// calculate thumbnail-height from given width to maintain aspect ratio
                                         
$imgw $width $height $imgh;                                          
                                         
// create new image using thumbnail-size
                                         
$thumb=imagecreatetruecolor($imgw,$imgh);                  
                                         
// copy original image to thumbnail
                                         
imagecopyresampled($thumb,$im,0,0,0,0,$imgw,$imgh,ImageSX($im),ImageSY($im)); //makes thumb
                                         
                                         
imagejpeg($thumb"test.jpg"80);  //imagejpeg($resampled, $fileName, $quality);            
                                         
$instr fopen("test.jpg","rb");  //need to move this to a safe directory
                                     
$image addslashes(fread($instr,filesize("test.jpg")));                        
                                         
mysql_query("UPDATE `user` SET `picture`= ( \"".$image."\") WHERE `userID`= '$userID' "); 
lo que hace es un resize antes del upload, espero que te sirva =)