Ir al contenido


Foto

Error Undefined index


  • Por favor identifícate para responder
2 respuestas en este tema

#1 josemlpere2001

josemlpere2001

    Newbie

  • Miembros
  • Pip
  • 3 mensajes

Escrito 31 mayo 2014 - 09:16

Este es el codigo:
Estoy usando la version 5.5.9


delphi
  1. <html>
  2. <head>
  3. <title>Uploade Archivo</title>
  4. </head>
  5. <body onload="document.form.reset();">
  6. <form action="procesa.php" method="post" enctype="multipart/form-data">
  7. <h3>Ingrese sus Datos</h3>
  8. <h6>Los Campos con (*) son obligatorios</h6>
  9. Nombre(*): <input type="text" name="nom" required/>
  10. <br/>
  11. Foto(*):<input type="file" name="img_up"/>
  12. <br/>
  13. <input type="submit" name="" value="Subir" title="Subir Archivo"/>
  14. </form>
  15. </body>
  16. </html>


Este es mi php:


delphi
  1. <?php
  2. require_once("../conexion/conexion.php");
  3. $foto=$_FILES["img_up"]["name"];
  4. $temp=$_FILES["img_up"]["tmp_name"];
  5. $tamano=$_FILES["img_up"]["size"];
  6. echo "La foto en el pc: <strong>$foto</strong>";
  7. echo "<br/>";
  8. echo "En el server: <strong>$temp</strong>";
  9. ?>


Este es mi error:


Notice: Undefined index: img_up in C:\xampp\htdocs\curso_php\up_imagen\Procesa.php on line 3

Notice: Undefined index: img_up in C:\xampp\htdocs\curso_php\up_imagen\Procesa.php on line 4
La foto en el pc:
En el server:

Espero que me puedan ayudar.


Edito para colocar un nombre al tema más coherente con el contenido del mismo...
  • 0

#2 enecumene

enecumene

    Webmaster

  • Administrador
  • 7.419 mensajes
  • LocationRepública Dominicana

Escrito 07 junio 2014 - 10:52

Debes definir el ID del Input:



delphi
  1. <br/>
  2. Foto(*):<input type="file" name="img_up" id="img_up"/>
  3. <br/>



Saludos.
  • 0

#3 porfi.dev

porfi.dev

    Advanced Member

  • Miembros
  • PipPipPip
  • 183 mensajes
  • LocationMy House @ México

Escrito 11 junio 2014 - 04:32

Amm nop necesariamente el ID y el NAME aunque son propiedades similares, no funcionan igual

en la pagina  para hacer un tipo debug haz esto

var_dump($_FILES);

Te mostrará el arreglo de los archivos, apra que veas como estan estructurados. Deberas ver algo asi:



delphi
  1. array(1) {
  2.     ["upload"]=>array(2) {
  3.         ["name"]=>array(2) {
  4.             [0]=>string(9)"file0.txt"
  5.             [1]=>string(9)"file1.txt"
  6.         }
  7.         ["type"]=>array(2) {
  8.             [0]=>string(10)"text/plain"
  9.             [1]=>string(10)"text/html"
  10.         }
  11.     }
  12. }




mas info aquí:

http://php.net/manua...ables.files.php
  • 0




IP.Board spam blocked by CleanTalk.