Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/11/2008, 13:07
begabi
 
Fecha de Ingreso: marzo-2006
Mensajes: 28
Antigüedad: 18 años, 1 mes
Puntos: 0
upload multiple e inserción en base de datos

Hola me estoy estrujando la cabeza con un upload de multiples filas que he de hacer dentro de un formulario:
No sé donde estoy fallando con el código pués ni me sube los archivos a la carpeta ni me registra los archivos de las fotos en la base de datos .Alguien me puede ayudar?
Este es el código:
<?
include("../includes/config.php");
include("../includes/funciones.php");
include("secure.php");
?>
<?php if(isset($_POST['submit'])){

$path1= "../fotos_pisos/".basename($_FILES['foto']['name'][0]);
$path2= "../fotos_pisos/".basename($_FILES['foto']['name'][1]);
$path3= "../fotos_pisos/".basename($_FILES['foto']['name'][2]);
$path4= "../fotos_pisos/".basename($_FILES['foto']['name'][3]);
$path5= "../fotos_pisos/".basename($_FILES['foto']['name'][4]);
$path6= "../fotos_pisos/".basename($_FILES['foto']['name'][5]);
$path7= "../fotos_pisos/".basename($_FILES['foto']['name'][6]);
$path8= "../fotos_pisos/".basename($_FILES['foto']['name'][7]);

$foto1 = $_FILES["foto"]["name"][0];
$foto2 = $_FILES["foto"]["name"][1];
$foto3 = $_FILES["foto"]["name"][2];
$foto4 = $_FILES["foto"]["name"][3];
$foto5 = $_FILES["foto"]["name"][4];
$foto6 = $_FILES["foto"]["name"][5];
$foto7 = $_FILES["foto"]["name"][6];
$foto8 = $_FILES["foto"]["name"][7];

move_uploaded_file($_FILES['foto']['tmp_name'][0], $path1);
move_uploaded_file($_FILES['foto']['tmp_name'][1], $path2);
move_uploaded_file($_FILES['foto']['tmp_name'][2], $path3);
move_uploaded_file($_FILES['foto']['tmp_name'][3], $path4);
move_uploaded_file($_FILES['foto']['tmp_name'][4], $path5);
move_uploaded_file($_FILES['foto']['tmp_name'][5], $path6);
move_uploaded_file($_FILES['foto']['tmp_name'][6], $path7);
move_uploaded_file($_FILES['foto']['tmp_name'][7], $path8);


$campos = "nombre,distrito,foto1,foto2,foto3,foto4,foto5,fot o6,foto7,foto8,descripcion,descripcion_en,descripc ion_fr,longitud,latitud";
$distrito = $_POST["distrito"];
$descripcion = $_POST["descripcion"];
$descripcion_en = $_POST["descripcion_en"];
$descripcion_fr = $_POST["descripcion_fr"];
$longitud = $_POST["longitud"];
$latitud = $_POST["latitud"];
$cnx = conectar();
$query="INSERT INTO ficha ($campos) VALUES(\"$nombre\", \"$distrito\", \"$foto1\", \"$foto2\", \"$foto3\",\"$foto4\",\"$foto5\", \"$foto6\", \"$foto7\",\"$foto8\",\"$descripcion\", \"$descripcion_en\",\"$descripcion_fr\",\"$longitu d\", \"$latitud\")";
$results=mysql_query($query) or die(mysql_error());
$AUTOID = mysql_insert_id($cnx);

$ArrayFechas = split(",",$_POST["HiddenArrayFechas"]);

for($a=0; $a< Count($ArrayFechas); $a++){
$Dia = split("/",$ArrayFechas[$a]);
$res = mysql_query("INSERT INTO diasreservados (id,diasReservado) VALUES('".$AUTOID."','".$Dia[2]."-".$Dia[1]."-".$Dia[0]." 00:00:00');") or die (mysql_error());
}
$titulo= "Noticia Insertada";
$mensaje = "La noticia ha sido publicada con éxito<br><br><br><a href='index.php'><< regresar</a>";
include("mensajes.php");
exit;
}//fin del while
//cerramos la conexión.
mysql_close($cnx);
?>
<?php include("header.php"); ?>
<table width="100%" height="277" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#eeeeee">
<tr>
<td width="150" valign="top" class="margen_menu"> <?php include("left.php"); ?></td>
<td width="850" valign="top">
<table width="100%" height="24" border="0">
<tr>
<TD width="100%" height="20"><div align="center" class="titulos">Insertar Piso</div></TD>
</tr>
</table>
<FORM action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST" name="formu" enctype="multipart/ form-data">
<table width="100%" border="0">
<tr>
<td colspan="2"><div align="center">Fechas reservadas<br />

<script type="text/javascript">
var idioma="es_ES";
</script>
<?php include("../includes/JSCalendario.html"); ?>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right"></div></td>
</tr>
<tr>
<td width="34%"><div align="right">Nombre:</div></td>
<td width="66%"><label>
<div align="left">
<input name="nombre" type="text" id="nombre" size="50" />
</div>
</label></td>
</tr>
<tr>
<td><div align="right">Distrito:</div></td>
<td><label>
<div align="left">
<input name="distrito" type="text" id="distrito" size="50" />
</div>
</label></td>
</tr>
<tr>
<td colspan="2" valign="top"><div align="center"><img src="../imagenes/es.gif" width="16" height="11" /> Descripci&oacute;n:</div> <label>
<div align="center">
<textarea name="descripcion" id="descripcion" cols="45" rows="5"></textarea>
</div>
</label></td>
</tr>

<tr>
<td colspan="2"><div align="center"><img src="../imagenes/gb.gif" width="16" height="11" /> Descripci&oacute;n:</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<label>
<textarea name="descripcion_en" id="descripcion_en" cols="45" rows="5"></textarea>
</label>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center"><img src="../imagenes/fr.gif" width="16" height="11" /> Descripci&oacute;n:</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<label>
<textarea name="descripcion_fr" id="descripcion_fr" cols="45" rows="5"></textarea>
</label>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">Fotos:</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<label>
<input type="file" name="foto[]" id="foto[]" />
</label>

</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="file" name="foto[]" id="foto[]" />
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="file" name="foto[]" id="foto[]" />
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="file" name="foto[]" id="foto[]" />
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="file" name="foto[]" id="foto[]" />
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="file" name="foto[]" id="foto[]" />
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="file" name="foto[]" id="foto[]" />
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="file" name="foto[]" id="foto[]" />
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">Coordenadas Google Maps: <a href="coordenadas.php" target="_blank">(Obtener coordenadas)</a></div></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
Longitud:
<input type="text" name="longitud" id="longitud" />
- Latitud:
<input type="text" name="latitud" id="latitud" />
</div>
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="submit" name="submit" id="submit" value="Agregar piso" />
</div>
</label></td>
</tr>
</table>
</FORM>
</table>

</td>
</tr>



</table>
</td></tr>
</table>
</body>
</html>

Gracias de antemano
Gabi