Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2011, 13:47
webAp
 
Fecha de Ingreso: noviembre-2011
Ubicación: Cordoba
Mensajes: 42
Antigüedad: 12 años, 6 meses
Puntos: 0
problema para editar fotos

un poco de ayuda porfavor, muestro el sig.form e donde traigo los datos del producto para editar y las fotos, estas las puedo eliminar y quitar del editorio bien, pero al editar me surge el problema , no puedo hacer funcionar el codigo para editar, ni en la base de datos ni en el directorio.

<form action="inventorio_edit.php" name="miform" id="miform" method="post">

<table cellspacing="0" cellpadding="0" style="height: 343px; width:84%;">
<tr>
<?php
$sql1 = mysql_query("SELECT * FROM fotoxproducto where idproducto='$elid' ");
$numrows = mysql_num_rows($sql1);
while($row_foto = mysql_fetch_array($sql1)){
$idfoto = $row_foto["idf"];
$namefoto = $row_foto["ruta_foto"];
?>
<td style="width: 117px; height: 116px">


<img src="../img_/<?php echo $namefoto; ?>" width="40" heigth="52" border="1" id="img" />
<a href="inventorio_edit.php?idfoto=<?php echo $idfoto ?>&rutafoto=<?php echo $namefoto; ?>&pid=<?php echo $elid; ?>">Eliminar</a>

<input name="editar" type="hidden" id="editar" value="<?php echo $idfoto; ?>"/>
<p>Editar</p>
<input type="file" name="archivos[]" />
</td>
<?php } ?>
</tr>



<td style="height: 25px; width: 117px">&nbsp;<strong>Nombre</strong></td>
<td style="height: 25px; width: 325px;"><label for="textfield"></label>
<input name="N__prod" type="text" id="N__prod" size="50" value="<?php echo $N__prod;?>" style="width: 180px" /></td>
</tr>
<tr>
<td style="height: 43px; width: 117px;"><strong>Precio</strong> </td>
<td style="height: 43px; width: 325px;"><label for="textfield2"></label>
<input name="P__prod" type="text" id="P__prod" size="20" value="<?php echo $P__prod;?>" style="width: 180px" /></td>
</tr>
<?php
function generaSelect()
{

global $idcategoria;
include 'conexion.php';
//include '../includes/sesionID.php';
conectar();

$consulta=mysql_query("SELECT id_categoria, nombre_ct FROM categorias where id_subcategoria = 0 ");


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>";
while($registro=mysql_fetch_row($consulta))
{?>
<option value="<?php echo $registro[0]; ?>" <?php if ($idcategoria == $registro[0]){ ?> selected = "selected" <?php } ?> ><?php echo $registro[1]; ?></option>
<?php } ?>
<?php
echo "</select>";} ?>



<tr>
<td style="width: 117px"><strong>Categoria</strong></td>
<td style="width: 325px">
<div id="demo" style="width:174px;">
<div id="demoIzq" disabled="disabled" style="width: 180px"><?php generaSelect(); ?>
<div id="demoMed">
<select name="select2" id="select2" style="width: 180px">
<option value="0">Selecciona opción...</option>

<?php
conectar();
$consulta2=mysql_query("SELECT * FROM categorias where id_subcategoria = '" . $idcategoria . "' ");
desconectar();
while($registro2=mysql_fetch_row($consulta2)){
?>
<option value="<?php echo $registro2[0]; ?>"<?php if ($idsubcategoria == $registro2[0]){ ?> selected = "selected" <?php } ?> ><?php echo $registro2[1];?></option>

<?php } ?>

</select>
</div>
<div id="demoDer">
<!-- <select disabled="disabled" name="select3" id="select3">
<option value="0">Selecciona opci&oacute;n...</option>
</select> -->
</div>
</div>
</div>

<label for="textfield3"></label>
<label for="select"></label>

</td>
</tr>

<tr>
<td style="width: 117px"><strong>Subcategoria</strong></td>
<td style="width: 325px"></td>
</tr>

<tr>
<td style="width: 117px"><strong>Descripción </strong> </td>
<td style="width: 325px"><label for="textarea"></label>
<textarea name="D__prod" id="D__prod" rows="5" style="width: 256px" ><?php echo $D__prod;?></textarea></td>
</tr>
<tr>
<td style="width: 117px">&nbsp;</td>
<td style="width: 325px">
<input type="hidden" name="el__id" value="<?php echo $elid; ?>" />
<input type="submit" name="button" id="button" value="Modificar" onclick="//javascript:return validarMyForm();" /></td>
</tr>
</table>
<p>&nbsp;</p>
</form>


este es el script php que estoy usando:
<?php
$idfoto =$_GET['idfoto'];
$sql = mysql_query("DELETE FROM fotoxproducto where idf='$idfoto' ")or die(mysql_error());


$ruta_foto =$_GET['rutafoto'];


$ruta_p_foto = ("../img_/$ruta_foto");

if(file_exists($ruta_p_foto)){
unlink($ruta_p_foto);}
?>
<?php

$img_ruta =$_FILES["archivos"];
if(isset($img_ruta)){
$name = $_FILES["archivos"]["name"];
$id =$_POST['editar'];
}
$sql3 = mysql_query("UPDATE fotoxproducto SET ruta_foto='$name' WHERE idf= '$id' ");

move_uploaded_file($_FILES['archivos']['tmp_name'],"../img_/$name");
?>