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

asi he hecho mi codigo, pero no me sube las imagenes, me tira error al momento de pasarlas a la carpeta, aclaro que tiene los permisos 777...

Código PHP:
<?php 
include("bd.php");
include(
"conexion.php");
$titulo $_POST['titulo'];
$descripcion $_POST['descripcion'];
$fecha $_POST['fecha'];
$password $_POST['password'];
$muestra=$_FILES['muestra']['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['muestra']['name'];
$ImagenNombre1=$_FILES['muestra1']['name'];
$ImagenNombre2=$_FILES['muestra2']['name'];
$ImagenNombre3=$_FILES['muestra3']['name'];
$ImagenNombre4=$_FILES['muestra4']['name'];
$ImagenNombre5=$_FILES['muestra5']['name'];
$ImagenNombre6=$_FILES['muestra6']['name'];
$ImagenNombre7=$_FILES['muestra7']['name'];
$dir "../imagenes/";
$dirmini "../imagenes/miniaturas/";

 
?>
<form enctype="multipart/form-data" name="add_news" method="post" action='add_news.php'>
<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 type="file" name="muestra[]" size="35" /></td>
</tr>
<tr>
  <td valign="top">
    <b>Muestra 1  :</b></td>
  <td colspan="2" valign="top">
 
  <input type="file" name="muestra[]" size="35" /></td>
</tr>
<tr>
  <td valign="top"><b>Muestra 2  :</b></td>
  <td colspan="2" valign="top">
 
  <input type="file" name="muestra[]" size="35" /></td>
</tr>
<tr>
  <td valign="top"><b>Muestra 3  :</b></td>
  <td colspan="2" valign="top">
 
  <input type="file" name="muestra[]" size="35" /></td>
</tr>
<tr>
  <td valign="top"><b>Muestra 4  :</b></td>
  <td colspan="2" valign="top">
 
  <input type="file" name="muestra[]" size="35" /></td>
</tr>
<tr>
  <td valign="top"><b>Muestra 5  :</b></td>
  <td colspan="2" valign="top">
 
  <input type="file" name="muestra[]" size="35" /></td>
</tr>
<tr>
  <td valign="top"><b>Muestra 6  :</b></td>
  <td colspan="2" valign="top">
 
  <input type="file" name="muestra[]" 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>
<?php


$N 
7//cantidad de archivos a subir
for($i=0$i<$N$i++) {

    if  (
is_uploaded_file($HTTP_POST_FILES['muestra']['tmp_name'][$i])) {
        
$no_doc $HTTP_POST_VARS['no_web_doc'][$i];
        
$split_path split("/"$HTTP_POST_FILES['muestra']['name'][$i]);

        
$split_path end ($split_path);

    if (
end($extension) == "jpeg" || end($extension) == "png") {

        echo 
"tipo de archivo invalido";

} else {

    
$RUTA_UPLOADED "../imagenes/";

        
$NOMBRE_FILE $split_path;
        
$muestraX[] = $split_path;

            
move_uploaded_file($HTTP_POST_FILES['muestra']['tmp_name'][$i], $RUTA_UPLOADED $NOMBRE_FILE);

$muestra $NOMBRE_FILE;


mysql_query("INSERT INTO templates
(titulo, fecha, descrpcion, muestra, muestra1, muestra2, muestra3, muestra4, muestra5, muestra6) VALUES('$titulo', '$fecha', '$descripcion', '$muestra', '$muestra1', '$muestra2', '$muestra3', '$muestra4', '$muestra5', '$muestra6') "

or die(
mysql_error());  
}
}
}
?>

nisiquiera me ingresa los demas datos a la base diciendome que la sentencia sql falla, probe con 2 o 3 maneras distintas de poner la sentencia y no me sube los datos tampoco...