Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/10/2004, 11:40
vanax
 
Fecha de Ingreso: marzo-2004
Mensajes: 50
Antigüedad: 20 años, 1 mes
Puntos: 0
hola,
alguien me puede decir porqué no me funciona este archivo para subir imagenes? Al enviar una imagen me saca el mensaje que tengo en el else de subearchivo.php(Ocurrió algún error al subir el fichero. No pudo guardarse.)
Estos son los archivos:

index.php
<html>
<head>
<title>Subir archivos</title>
</head>

<body>
<form action="http://localhost/pruebaimagenes/subearchivo.php" method="post" enctype="multipart/form-data">
<b>Campo de tipo texto:</b>
<br>
<input type="text" name="cadenatexto" size="20" maxlength="100">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<br>
<br>
<b>Enviar un nuevo archivo: </b>
<br>
<input name="userfile" type="file">
<br>
<input type="submit" value="Enviar">
</form>
</body>
</html>
-----subearchivo.php

<html>
<head>
<title>Subiendo una nueva foto</title>
</head>

<body>
<h1>Subiendo un archivo</h1>
<br>
<div align="center">
<?
//tomo el valor de un elemento de tipo texto del formulario
$cadenatexto = $_POST["cadenatexto"];
echo "Escribió en el campo de texto: " . $cadenatexto . "<br><br>";

//datos del arhivo
$nombre_archivo = $HTTP_POST_FILES['userfile']['name'];
$tipo_archivo = $HTTP_POST_FILES['userfile']['type'];
$tamano_archivo = $HTTP_POST_FILES['userfile']['size'];
//compruebo si las características del archivo son las que deseo
if (!((strpos($tipo_archivo, "gif") || strpos($tipo_archivo, "jpeg")) && ($tamano_archivo < 100000))) {
echo "La extensión o el tamaño de los archivos no es correcta. <br><br><table><tr><td><li>Se permiten archivos .gif o .jpg<br><li>se permiten archivos de 100 Kb máximo.</td></tr></table>";
}else{
if (move_uploaded_file($HTTP_POST_FILES['userfile']['C:\AppServ\www\pruebaimagenes\imagenes'], $nombre_archivo)){
echo "El archivo ha sido cargado correctamente.";
}
else{
echo "Ocurrió algún error al subir el fichero. No pudo guardarse.";
}
}
?>
<br>
<br>

<a href="index.php">Volver</a>
<br>
</div>
</body>
</html>