Foros del Web » Programando para Internet » PHP »

Subir imágenes a través de un formulario

Estas en el tema de Subir imágenes a través de un formulario en el foro de PHP en Foros del Web. Hola a todos, yo se que en el foro es un tema que se ha tocado mil y un veces, sin embargo, no logro hacer ...
  #1 (permalink)  
Antiguo 02/08/2011, 15:35
Avatar de DanielGoGo  
Fecha de Ingreso: agosto-2011
Mensajes: 15
Antigüedad: 12 años, 8 meses
Puntos: 0
Pregunta Subir imágenes a través de un formulario

Hola a todos, yo se que en el foro es un tema que se ha tocado mil y un veces, sin embargo, no logro hacer que funcione...

Mi código es el siguiente:

Para enviar el formulario:
<form name="registro" action="registraint.php" method="POST">
<table>
<tr>
<td>Imagen</td><td><input type="file" size="32" name="archivo" id="archivo"></td>
</tr>
<tr>
<td><input type="submit" value="Enviar"></td>
</tr>
</table>
</form>

Para copiar la imagen:
$directorio_archivo = "../imgInt/";
$nombre = strtr($_FILES['archivo']['name'], "ñ'ÁÉÍÓÚÀÈÌÒÙáéíóúäëïöüàèìòù ", "n-AEIOUAEIOUaeiouaeiouaeiou_");
$tamanio = $_FILES['archivo']['size'];
$tipo = $_FILES['archivo']['type'];
copy($_FILES['archivo']['tmp_name'], $directorio_archivo.$nombre);

Y me sale los siguientes errores/warnings/notices:

Notice: Undefined index: archivo in C:\Documents and Settings\...\xampp\htdocs\...\registraint.php on line 17

Notice: Undefined index: archivo in C:\Documents and Settings\...\xampp\htdocs\...\registraint.php on line 18

Notice: Undefined index: archivo in C:\Documents and Settings\...\xampp\htdocs\...\registraint.php on line 19

Notice: Undefined index: archivo in C:\Documents and Settings\...\xampp\htdocs\...\registraint.php on line 20

Warning: copy() [function.copy]: Filename cannot be empty in C:\Documents and Settings\...\xampp\htdocs\...\registraint.php on line 20
  #2 (permalink)  
Antiguo 02/08/2011, 15:41
Avatar de jotaincubus  
Fecha de Ingreso: mayo-2005
Ubicación: Medellin - Colombia
Mensajes: 1.797
Antigüedad: 18 años, 11 meses
Puntos: 394
Respuesta: Subir imágenes a través de un formulario

Amigo para trabajar con archivos en un formulario necesitas usar enctype="multipart/form-data"
__________________
Por que existe gente que no agradece después de que se le ha brindado tiempo y ayuda ???
  #3 (permalink)  
Antiguo 02/08/2011, 15:45
Avatar de DanielGoGo  
Fecha de Ingreso: agosto-2011
Mensajes: 15
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: Subir imágenes a través de un formulario

Gracias amigo!!!
Has salvado mi vida!!

Etiquetas: formulariophp, subirarchivos, subirimagenes
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:07.