Upload multipli

Tengo un pequeño detalle con este codigo cuando guardo sin id se almacena pero cuando le coloco el campo id incrementable no guarda los nombre o los datos en base de datos
formulario
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>
<body>
<form enctype="multipart/form-data" action="add.php" method="POST">
<p>Photo:
  <input type="file" name="photo">
  </p>
<p>
    <input type="file" name="photo2" />
  </p>
<p>
    <input type="file" name="photo3" />
  </p>
<p>
    <input type="file" name="photo4" />
  </p>
<p>
    <input type="file" name="photo5" />    
    <br>
    <input type="submit" value="Add">
  </p>
</form>
</body>
</html>
add.php
<?php
 error_reporting (0);
 //This is the directory where images will be saved
 $target = "images/";
 $target = $target . Basename( $_FILES['photo']['name']);
 //This gets all the other information from the form
 $pic=($_FILES['photo']['name']);
 $pic2=($_FILES['photo2']['name']);
 $pic3=($_FILES['photo3']['name']);
 $pic4=($_FILES['photo4']['name']);
 $pic5=($_FILES['photo5']['name']);  
 // Connects to your Database
 mysql_connect("localhost", "root", "") or die(mysql_error()) ;
 mysql_select_db("test") or die(mysql_error()) ;
 //Writes the information to the database
 mysql_query("INSERT INTO test1 VALUES ('$pic','$pic2','$pic3','$pic4','$pic5')") ;
 //Writes the photo to the server
 if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
 {
 //Tells you if its all ok
 echo "". Basename( $_FILES['uploadedfile']['name']). "";
 }
 else { {
 //Gives and error if its not
 echo "";
 }
 }
  $target = $target . Basename( $_FILES['photo2']['name']);
  if(move_uploaded_file($_FILES['photo2']['tmp_name'], $target))
 {
 //Tells you if its all ok
 echo "". Basename( $_FILES['uploadedfile']['name']). "";
 }
 else { {
 //Gives and error if its not
 echo "";
 }
 }
  $target = $target . Basename( $_FILES['photo3']['name']);
  if(move_uploaded_file($_FILES['photo3']['tmp_name'], $target))
 {
 //Tells you if its all ok
 echo "". Basename( $_FILES['uploadedfile']['name']). "";
 }
 else { {
 //Gives and error if its not
 echo "imagenes";
 }
 }
  $target = $target . Basename( $_FILES['photo4']['name']);
  if(move_uploaded_file($_FILES['photo4']['tmp_name'], $target))
 {
 //Tells you if its all ok
 echo "". Basename( $_FILES['uploadedfile']['name']). "las imagenes se han cargado correctamente";
 }
 else { {
 //Gives and error if its not
 echo "Disculpe las molestia, vuelva cargar las imagenes";
 }
 }
  $target = $target . Basename( $_FILES['photo5']['name']);
  if(move_uploaded_file($_FILES['photo5']['tmp_name'], $target))
 {
 //Tells you if its all ok
 echo "The file ". Basename( $_FILES['uploadedfile']['name']). "las imagenes se han cargado correctamente";
 }
 else { {
 //Gives and error if its not
 echo "Disculpe las molestia, vuelva cargar las imagenes";
 }
 }
 ?>
en un upload multiple como resuelvo eso porfavor

1 Respuesta

Respuesta
1
Haz un echo del query que utilizas:
mysql_query("INSERT INTO test1 VALUES ('$pic','$pic2','$pic3','$pic4','$pic5')") ;
Para saber lo que le está llegando a la BD
sip pero con le agrego a la tabla el campo id no me guarda pero cuando lo elimino me guarda
Si es autonumerico, no lo puedes agregar tu, deberias de crear otro campo id para almacenar el identificador de la imagen

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas