Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/01/2012, 15:00
oliverarthurnardi
 
Fecha de Ingreso: noviembre-2010
Ubicación: aun no se donde vivir
Mensajes: 112
Antigüedad: 14 años, 4 meses
Puntos: 3
Porque esto no me funciona

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
  1. <script type="text/javascript">
  2.   function SubirImagen()
  3.   {
  4.     self.name = 'oponer';
  5.     remote = open('imagenproducto.php', 'remote',
  6.     'width=450,height=250,location=no,scroll=yes,menubar=no,toolbars=no,resizable=yes,fullscreen=no,status=yes, titlebar=yes');
  7.     remote.focus();
  8.       }
  9.   </script>
  10. <div class="content">
  11.     <h2>A&ntilde;adir producto    </h2>
  12.     <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  13.      <tr valign="baseline">
  14.           <td nowrap="nowrap" align="right">Photo:</td>
  15.           <td><input name="photo" type="text"  id="photo" size="15" />
  16.           <input type="button" name="button" id="button" value="Subir imagen" onclick="javascript:SubirImagen();"/></td>
  17.         </tr>

imagenproducto.php
Código Javascript:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Subir Imagen</title>
  6. </head>
  7.  
  8.  
  9. <body>
  10. <?php
  11. if ((isset($_POST["enviado"])) && ($_POST["enviado"] == "form1")) {
  12.   $nombre_archivo = $_FILES['userfile']['name'];
  13.   move_uploaded_file($_FILES['userfile']['tmp_name'],"../imagenes/productos/".$nombre_archivo);  
  14.  
  15.   ?>
  16.   <script type="text/javascript">
  17.     oponer.document.form1.photo.value="<?php echo $nombre_archivo; ?>";
  18.     self.close();
  19.   </script>
  20.   <?php
  21. }
  22. else
  23. {
  24.    
  25. ?>
  26. <form action="imagenproducto.php" method="post" enctype="multipart/form-data" id="form1">
  27.  
  28.   <p>
  29.     <input name="userfile" type="file" />
  30.   </p>
  31.   <p><input type="submit" name="button" id="button" value="Subir Imagen"/> </p>
  32.   <p><input type="hidden" name="enviado" value="form1"/></p>
  33. </form>
  34. <?php } ?>
  35. </body>
  36. </html>