Hola buenas chicos alguien de por aqui me puede ayudar a identificar porque este js no me funciona.. Lo que debe hacer el js es que al yo subir el archivo la ventana emergente "imagenproducto.php" se me deberia cerrar y el archivo se me deberia cargar en el campo Photo del documento producto_add.php
producto_add.php
Código Javascript
:
Ver original<script type="text/javascript">
function SubirImagen()
{
self.name = 'oponer';
remote = open('imagenproducto.php', 'remote',
'width=450,height=250,location=no,scroll=yes,menubar=no,toolbars=no,resizable=yes,fullscreen=no,status=yes, titlebar=yes');
remote.focus();
}
</script>
<div class="content">
<h2>Añadir producto </h2>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Photo:</td>
<td><input name="photo" type="text" id="photo" size="15" />
<input type="button" name="button" id="button" value="Subir imagen" onclick="javascript:SubirImagen();"/></td>
</tr>
imagenproducto.php
Código Javascript
:
Ver original<!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>Subir Imagen</title>
</head>
<body>
<?php
if ((isset($_POST["enviado"])) && ($_POST["enviado"] == "form1")) {
$nombre_archivo = $_FILES['userfile']['name'];
move_uploaded_file($_FILES['userfile']['tmp_name'],"../imagenes/productos/".$nombre_archivo);
?>
<script type="text/javascript">
oponer.document.form1.photo.value="<?php echo $nombre_archivo; ?>";
self.close();
</script>
<?php
}
else
{
?>
<form action="imagenproducto.php" method="post" enctype="multipart/form-data" id="form1">
<p>
<input name="userfile" type="file" />
</p>
<p><input type="submit" name="button" id="button" value="Subir Imagen"/> </p>
<p><input type="hidden" name="enviado" value="form1"/></p>
</form>
<?php } ?>
</body>
</html>