Ver Mensaje Individual
  #19 (permalink)  
Antiguo 24/09/2010, 08:55
marilinadg
 
Fecha de Ingreso: enero-2007
Ubicación: perdida entre líneas de código...
Mensajes: 235
Antigüedad: 17 años, 3 meses
Puntos: 1
Respuesta: Galeria fotos Jquery

Perdón pero no se sio entendí bien, a ver el archivo cargar.php me quedó asi:

<?php
function resize($img, $thumb_width, $newfilename)
{
$max_width=$thumb_width;

//Check if GD extension is loaded
if (!extension_loaded('gd') && !extension_loaded('gd2'))
{
trigger_error("GD is not loaded", E_USER_WARNING);
return false;
}

//Get Image size info
list($width_orig, $height_orig, $image_type) = getimagesize($img);

switch ($image_type)
{
case 1: $im = imagecreatefromgif($img); break;
case 2: $im = imagecreatefromjpeg($img); break;
case 3: $im = imagecreatefrompng($img); break;
default: trigger_error('Unsupported filetype!', E_USER_WARNING); break;
}

/*** calculate the aspect ratio ***/
$aspect_ratio = (float) $height_orig / $width_orig;

/*** calulate the thumbnail width based on the height ***/
$thumb_height = round($thumb_width * $aspect_ratio);


while($thumb_height>$max_width)
{
$thumb_width-=10;
$thumb_height = round($thumb_width * $aspect_ratio);
}

$newImg = imagecreatetruecolor($thumb_width, $thumb_height);

/* Check if this image is PNG or GIF, then set if Transparent*/
if(($image_type == 1) OR ($image_type==3))
{
imagealphablending($newImg, false);
imagesavealpha($newImg,true);
$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
imagefilledrectangle($newImg, 0, 0, $thumb_width, $thumb_height, $transparent);
}
imagecopyresampled($newImg, $im, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);

//Generate the file, and rename it to $newfilename
switch ($image_type)
{
case 1: imagegif($newImg,$newfilename); break;
case 2: imagejpeg($newImg,$newfilename); break;
case 3: imagepng($newImg,$newfilename); break;
default: trigger_error('Failed resize image!', E_USER_WARNING); break;
}

return $newfilename;
}

echo resize("test4.png", 120, "thumb_test4.png")

?>

/*hasta acá lo que copié de lo que me pasaste*/

/*desde acá lo que ya tenía en el archivo cargar.php*/
<?php

/*Aqui haces la conexion a tu base de datos*/

if(vecinoma_admin($_FILES['Foto']['name']))
{

$aleatorio = mt_rand(1,1000);
$directorio = "images/";
$directorio = $directorio. $aleatorio . vecinoma_admin( $_FILES['Foto']['name']);

move_uploaded_file($_FILES['Foto]['tmp_name], $directorio);

}

$sql = "INSERT INTO nombre_tabla (titulo, descripcion, url_foto) VALUES ('".$_POST['Titulo']."','".$_POST['Descripcion']."','$directorio')";
mysql_query(sql) or die('Error al guardar por: ' . mysql_error());

?>

DEonde de paso comento que donde decía basename lo cambié por el nombre de mi base de datos, eso está bien no?
Bueno ahora, si lo anterior está bien, el código que mencionás para llamar la función dónde tendría que ponerlo?

Gracias por la paciencia, podré terminarlo para hoy??? veremos, veremos...

Última edición por marilinadg; 24/09/2010 a las 09:01