Ver Mensaje Individual
  #32 (permalink)  
Antiguo 24/09/2010, 13:40
Avatar de JoseAlejandro_Realza
JoseAlejandro_Realza
 
Fecha de Ingreso: agosto-2008
Ubicación: Maracay - Venezuela
Mensajes: 192
Antigüedad: 15 años, 8 meses
Puntos: 2
Respuesta: Galeria fotos Jquery

Has lo siguiente, en la seccion del codigo donde guardas la imagen, cambialo por esto ->

Código PHP:
    
            
if(basename($_FILES['Foto']['name'])) {

                       include(
"dimensionar.php");

            
$aleatorio mt_rand(1,1000);
            
$directorio "images/";
            
$directorio $directorio$aleatorio basename$_FILES['Foto']['name']); 
            
$diferencial 'images/thum_';
            
$nueva_imagen $diferencial $aleatorio basename$_FILES['Foto']['name']);


            
move_uploaded_file($_FILES['Foto_Principal']['tmp_name'], $directorio);
              
                
$tam=getimagesize($directorio);  
                
                if(
$tam[0] > 700 OR $tam[1] > 400
                    { 
                    
dimensionar($directorio$directorio700400); 
                    } 
                    
                
dimensionar($directorio$nueva_imagen200200); 
            } 
Luego creas otro archivo con el nombre "dimensionar.php" y le agregas esta funcion:

Código PHP:

function dimensionar($nombre,$archivo,$ancho,$alto
    { 
    
$verificar explode('.',$nombre);
    
$tmp $verificar[1]; 

    if (
preg_match('/jpg|jpeg|JPG/',$tmp)) 
        { 
        
$imagen=imagecreatefromjpeg($nombre); 
        } 
    if (
preg_match('/png|PNG/',$tmp)) 
        { 
        
$imagen=imagecreatefrompng($nombre); 
        } 
    if (
preg_match('/gif|GIF/',$tmp)) 
        { 
        
$imagen=imagecreatefromgif($nombre); 
        } 

    
$x=imageSX($imagen); 
    
$y=imageSY($imagen); 

    if (
$x $y)  
        { 
        
$w=$ancho
        
$h=$y*($alto/$x); 
        } 

    if (
$x $y)  
        { 
        
$w=$x*($ancho/$y); 
        
$h=$alto
        } 

    if (
$x == $y)  
        { 
        
$w=$ancho
        
$h=$alto
        } 


    
$destino=ImageCreateTrueColor($w,$h); 
   
imagecopyresampled($destino,$imagen,0,0,0,0,$w,$h,$x,$y);  


    if (
preg_match("/png/",$tmp)) 
        { 
        
imagepng($destino,$archivo);  
        }  
    if (
preg_match("/gif/",$tmp)) 
        { 
        
imagegif($destino,$archivo); 
        } 
    else  
        { 
        
imagejpeg($destino,$archivo);  
        } 

    
imagedestroy($destino);  
   
imagedestroy($imagen);  

Con esto debería bastar, finalmente solo faltara que en el SQL, agregues la variable $directorio en la foto grande, y $nueva_imagen para guardar el thumbnail. Saludos
__________________
Tu Guía Empresarial http://www.empresarial.org.ve Soluciones Empresariales

Atte: José Alejandro Realza