Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/04/2007, 12:06
cpuser
 
Fecha de Ingreso: diciembre-2005
Ubicación: Mar del Plata
Mensajes: 146
Antigüedad: 18 años, 4 meses
Puntos: 2
multiples uploads - thumbnails

que tal,

estoy intentando hacer un sistema de multiples uploads de imagenes y que a su vez genere de todas esas imagenes, sus respectivos thumbnails,

los nombres de las imagenes que se suben deben ir a la base de datos, y los archivos directamente al servidor, pero la verdad es que no tengo idea como hacerlo, eh googleado bastante y no encontre la solucion, y por eso recurro al foro.

yo creo que lo mas complicado pasa por el lado de que una de las imagenes, tiene que tener un valor de alto*ancho y las restantes otro.

este es el codigo que tengo hasta ahora, pero claro, solo funcionaria con una sola imagen, y necesito que funcione con las 7 imagenes especificadas

espero que alguien me pueda ayudar,

Muchas gracias,

Cpuser

Código PHP:
<?php 
include("config.php");
include(
"mysql.php");
$titulo $_POST['titulo'];
$descripcion $_POST['descripcion'];
$fecha $_POST['fecha'];
$password $_POST['password'];
$imgcentral=$_FILES['imgcentral']['name'];
$muestra1=$_FILES['muestra1']['name'];
$muestra2=$_FILES['muestra2']['name'];
$muestra3=$_FILES['muestra3']['name'];
$muestra4=$_FILES['muestra4']['name'];
$muestra5=$_FILES['muestra5']['name'];
$muestra6=$_FILES['muestra6']['name'];

$tamanominimoancho=300;
function 
createThumb($image$newname,$tamanominimoancho){    
    
$size getimagesize ($image);
    
$tipoexif_imagetype($image);
    
$height $size[1];
    
$width $size[0];

        
    if (
$width $height) {
        
$newwidth $tamanominimoancho;
        
$newheight round(($height*$tamanominimoancho)/$width);
    } else {
        
$newheight $tamanominimoancho;
        
$newwidth round(($width*$tamanominimoancho)/$height);    
    }
switch(
$tipo){
case 
'2':
$src = @imagecreatefromjpeg($image) or die("problemas con la imagen $image"); 
break;
case 
'1':
$src = @imagecreatefromgif($image) or die("problemas con la imagen $image"); 
break;
case 
'3':
$src = @imagecreatefrompng($image) or die("problemas con la imagen $image"); 
break;
}        
    
    
$im imagecreatetruecolor($newwidth,$newheight);
    
imagecopyresampled($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
    
//echo $newname;
    
imagejpeg($im$newname,50);
    
imagedestroy($im);
}
$ImagenNombre=$_FILES['imgcentral']['name'];
$dir "../imagenes/";
$dirmini "../imagenes/miniaturas/";

if (
$submit == "") { ?>
<form method="post" action="add_news.php" name="add_news">
<table width="477" cellspacing="3" cellpadding="0">
  <!--DWLayoutTable-->
<tr>
<td width="164" valign="top">
  <b>Titulo:</b></td>
<td colspan="2" valign="top">
  <input type="text" name="titulo" size="35"></td>
</tr>
<tr>
<td valign="top">
  <b>Fecha:</b></td>
<td colspan="2" valign="top">
  <input type="text" name="fecha" size="35"></td>
</tr>
<tr>
<td valign="top">
  <b>Descripcion:</b></td>
<td colspan="2" valign="top">
  <textarea name="descripcion" cols="35" rows="3"></textarea></td>
</tr>
<tr>
  <td valign="top">
    <b>Imagen central :</b></td>
<td colspan="2" valign="top">
  <input name="imgcentral" type="file" value="" size="35" /></td>
</tr>


<tr>
  <td valign="top">
    <input type="password" name="password" size="5"></td>
<td width="79" valign="top">
    <input type="submit" name="submit" value="Crear template"></td>
<td width="214"></td>
</tr>

<tr>
  <td></td>
  <td></td>
  <td></td>
</tr>
</table>
</form>
<?
}

$base_path "../imagenes/".$_FILES['imgcentral']['name'];

copy($_FILES['imgcentral']['tmp_name'], $base_path);
chmod ($base_path0644);

$image_path "../imagenes/" $_FILES['imgcentral']['name'];
createThumb($dir.$ImagenNombre$dirmini."mini_".$ImagenNombre,$tamanominimoancho);

if ((
$submit == "Crear template") && ($titulo != "") && ($fecha != "") && ($descripcion != "") && ($password == "$admin_pass") && ($imgcentral != "") && ($muestra1 != "") && ($muestra2 != "") && ($muestra3 != "") && ($muestra4 != "") && ($muestra5 != "") && ($muestra6 != "") ) {
echo 
"Ya puede utilizar su nuevo template";
mysql_query("INSERT INTO templates
(titulo, fecha, descrpcion, imgcentral, muestra1, muestra2, muestra3, muestra4, muestra5, muestra6) VALUES('$titulo', '$fecha', '$descripcion', '$imgcentral', '$muestra1', '$muestra2', '$muestra3', '$muestra4', '$muestra5', '$muestra6') "

or die(
mysql_error()); 
}
?>