Tengo este formulario para crear varias fotos de un producto en una tabla aparte con el id de producto y ya estoy muy alterado de no poder actualizarlas, no encuentro la forma de actualizar las imagenes , el codigo que utilizo no mueve para nada y probe de mil formas, no entiendo realmente por eso pido ayuda, no puedo actualizar ni en la tabla ni en el directorio las fotos que inserto.
Código PHP:
Ver original
<?php //analizar form, agregar producto $idsubcat = $_POST['select2']; $img =$_FILES["archivos"]; //de se asi, para procesar los archivos subidos al servidor solo debemos recorrerlo //obtenemos la cantidad de elementos que tiene el arreglo archivos for ($i = 0; $i < $tot; $i++){ $name = $_FILES["archivos"]["name"][0]; $name1 = $_FILES["archivos"]["name"][1]; $name2 = $_FILES["archivos"]["name"][2]; $name3 = $_FILES["archivos"]["name"][3]; } } //vemos si el nombre de producto es identico a otro producto del sistema if($P__coincidencia > 0){ echo 'Disculpe, trato de crear un producto que ya existe ,<a href="inventorio.php">click aca</a>'; } VALUES('$nombre__prod','$precio__prod','$detalles__prod',now(),$id_ct,'$idsubcat')") or die(mysql_error()); //$pid = mysql_insert_id(); //imagen //$nw__img = "$pid.jpg"; //move_uploaded_file($_FILES['fileField']['tmp_name'],"../eCommIMG/$nw__img"); } ?> <?php $productos__listados = ""; if($productos__contados > 0){ $id__p = $col["id"]; $nombre__prod = $col["nombreProd"]; $productos__listados .= "$dia__added - $id__p - $nombre__prod <a href='inventorio.php?eliminarid=$id__p'> eliminar</a> • <a href='inventorio_edit.php?pid=$id__p'>editar</a><br/>" ; } }else{ $productos__listados = "Usted no tiene una lista de productos todavia" ; } ?> <body> <div class="main2"> <div class="header"> <div class="header_resize"> <div class="logo"> <h1><a href="index.html">K<span>D</span>L</a><small> Administración General</small></h1> </div> <div class="menu_nav"> <ul> <li><a href="l_inventorio.php">Productos</a></li> <li><a href=""></a></li> <li><a href=""></a></li> <li><a onclick="return confirmar('Esta seguro que desea salir del sistema?')" href="../admin/index.php?out=1"> <img src="images/icon_logout.png" border="0" width="30" /> <span style="color:white"></span></a></li> </ul> <div class="clr"></div> </div> <div class="clr"></div> <div class="header_img"> <h3><center> </center></h3> <div class="clr"></div> </div> </div> </div> <div class="clr"></div> <div class="content"> <div class="content_resize"> <div class="mainbar2"> <div class="article"> <form action="inventorio.php" enctype="multipart/form-data" name="miform" id="miform" method="post"> <h3>Nuevo Producto </h3> <table width="100%" cellpadding="0" cellspacing="0" > <tr> <td width="43%" > <a name="inventorioform" id="inventorioform"></a> <table width="80%" cellspacing="0" cellpadding="0" align="left"> <tr> <td ><dl> <dt><label><span style="font-size:medium">Imagen a Subir:</span></label></dt> <!-- Esta div contendrá todos los campos file que creemos --> <dd><div id="adjuntos" style="font-size:x-small;"> <!-- Hay que prestar atención a esto, el nombre de este campo debe siempre terminar en [] como un vector, y ademas debe coincidir con el nombre que se da a los campos nuevos en el script --> <input type="file" name="archivos[]" style="width: 215px" /><br /> </div></dd> <dt><a href="#" onClick="addCampo()"><span style="font-size:small">Subir otra imagen</span></a></dt> <dd><!-- <input type="submit" value="Enviar" id="envia" name="envia" /> --></dd> </dl></td> </tr> <tr> <td width="166" ><strong>Nombre</strong></td> <td colspan="4"><label for="textfield"></label> <input name="N__prod" type="text" id="N__prod" size="40" style="width: 180px" /></td> </tr> <tr> <td style="height: 12px" ></td> <td colspan="4" style="height: 12px"></td> </tr> <tr> <td style="height: 18px"><strong>Precio</strong></td> <td colspan="4" style="height: 18px"><label for="textfield2"></label> <input name="P__prod" type="text" id="P__prod" size="40" style="width: 180px" /></td> </tr> <?php function generaSelect() { include 'conexion.php'; //include '../includes/sesionID.php'; conectar(); desconectar(); // Voy imprimiendo el primer select compuesto por los paises echo "<select name='select1' id='select1' onChange='cargaContenido(this.id)' style='width:180px;'>"; echo "<option value='0'>Elige</option>"; { echo "<option value='".$registro[0]."'>".$registro[1]."</option>"; } echo "</select>"; } ?> <tr> <td style="height: 76px"><strong>Categoria<br/>Subcategoria</strong></td> <td colspan="4" style="height: 76px"> <div id="demo" style="width:600px;"> <div id="demoIzq"><?php generaSelect(); ?></div> <div id="demoMed"> <select disabled="disabled" name="select2" id="select2" style="width:180px;"> <option value="0">Selecciona opción...</option> </select> </div> <div id="demoDer"> <!--<input type="hidden" name="select3" id="select3" style="width: 180px"/> <select disabled="disabled" name="select3" id="select3"> <option value="0">Selecciona opción...</option> </select> </div>--> </div> <!-- <select name="cate" id="cate"> <?php echo " <option"; if ($sql_ct == $row) { echo " selected"; } echo " value="; echo $row[0] ; echo ">", $row[1],"</option>\n"; } ?> </select>--> </td> </tr> <tr> <td> </td> <td colspan="4"> <!-- <select name="subcate" id="subcate"> <?php echo " <option"; if ($sql_st==$row) { echo "selected"; } echo " value="; echo $row[0] ; echo ">", $row[1],"</option>\n"; } ?> </select>--></td> </tr> <?php /** TO DO */ /* insertar en area de texto palabras claves para la busqueda del producto */ ?> <tr> <td></td> <td colspan="4"></td> </tr> <tr> <td><strong>Descripción</strong></td> <td colspan="4"><label for="textarea"></label> <textarea name="D__prod" id="D__prod" rows="5" style="width: 232px"></textarea></td> </tr> <tr> <td><input type="hidden" name="act" value="1"/></td> <td colspan="4"><input type="submit" name="button" id="button" value="Enviar" onclick="javascript:return validarMyForm();" /></td> </tr> </table> </td></tr> </table> </form></div>
tablas
Código SQL:
Ver original
CREATE TABLE IF NOT EXISTS `productos` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `nombreProd` VARCHAR(245) NOT NULL, `precio` VARCHAR(16) NOT NULL, `detalles` text NOT NULL, `id_ct` INT(16) NOT NULL, `subcategoria` VARCHAR(50) NOT NULL, `dia_added` DATE NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `nombreProd` (`nombreProd`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=51 ; CREATE TABLE IF NOT EXISTS `fotoxproducto` ( `idf` INT(255) NOT NULL AUTO_INCREMENT, `ruta_foto` VARCHAR(50) NOT NULL, `idproducto` INT(11) NOT NULL, PRIMARY KEY (`idf`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;