Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/10/2004, 11:51
xakilixutt
 
Fecha de Ingreso: noviembre-2002
Ubicación: España
Mensajes: 24
Antigüedad: 21 años, 5 meses
Puntos: 0
subir imagenes al servidor

Hola a todos:
Quiero realizar una página para poder subir imagenes a servidor y no consigo hacerlo, envio el código que utilizo a ver si alguien me puede reportar el error que estoy cometiendo.
Gracias a todos de antemano por atender este mensaje. saludos.


<html>
<body>
<form action="enviar_imagen.php" method="post" enctype="multipart/form-data" name="form1">
<table width="485" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="485">cadenatexto
<input name="cadenatexto" type="text" id="cadenatexto">
<input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value="100000"></td>
</tr>
<tr>
<td>enviar un nuevo archivo&nbsp;
<input name="userfile" type="file" >
<input type="submit" name="Submit" value="Enviar"> </td>
</tr>
</table>
</form>
</body>
</html>




<html>
<body>
<?php
$cadenatexto=$_POST["cadenatexto"];
echo "Escribió en el campo de texto: ".$cadenatexto. "<br><br>\n";

$nombre_archivo=$HTTP_POST_FILES['userfile']['name'];
$tipo_archivo=$HTTP_POST_FILES['userfile']['type'];
$tamano_archivo=$HTTP_POST_FILES['userfile']['size'];

if(!((strpos($tipo_archivo, "gif") || strpos($tipo_archivo, "jpg") && strpos($tamano_archivo < 100000))){
echo "no es correcta";
}else{
if(move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], $nombre_archivo)){
echo "el archivo se ha cargado bien";
}else{
echo "ocurrió un error";
}
}

?>
</body>
</html>