🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.php
Article #151

upload multiple e inserci�n en base de datos

#151
From: Gabi
Date: Thu, 20 Nov 2008 19:05
238 lines
8406 bytes
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,foto6,foto7,foto8,descripcion,descripcion_en,descripcion_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\",\"$longitud\", \"$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
Technical Details
Message-ID: <gg4cd7$s2g$1@aioe.org>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!aioe.org!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 107579,952bb00882125fdc,start
X-Google-Attributes: gid107579,domainid0,public,usenet
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!aioe.org!not-for-mail
From: "Gabi" <begabi@telefonica.net>
Newsgroups: es.comp.lenguajes.php
Subject: upload multiple e inserci�n en base de datos
Date: Thu, 20 Nov 2008 20:05:08 +0100
Organization: Aioe.org NNTP Server
Lines: 241
Message-ID: <gg4cd7$s2g$1@aioe.org>
NNTP-Posting-Host: 2vNEWo9Up0FRKdIarYurrg.user.aioe.org
X-Complaints-To: abuse@aioe.org
NNTP-Posting-Date: Thu, 20 Nov 2008 19:05:12 +0000 (UTC)
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
X-RFC2646: Format=Flowed; Original
X-Notice: Filtered by postfilter v. 0.7.4
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-Priority: 3
X-MSMail-Priority: Normal