Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/10/2009, 11:45
Aioros-jms
 
Fecha de Ingreso: julio-2008
Mensajes: 116
Antigüedad: 15 años, 9 meses
Puntos: 1
Pregunta Subir imagenes al servidor - PHP -

Hola que tal!!!

Estoy intentando hacer en script en PHP, donde pueda subir imagenes por medio de una página, sin embargo con lo poco que tengo no lo hace, me podrían auxiliar!!!

Código HTML

Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Subir archivos</title>
	<link rel="STYLESHEET" type="text/css" href="estilos_admin.css">
</head>

<body>
<h1>Subir archivos</h1>
<br>
	<form action="subearchivo.php" method="post" enctype="multipart/form-data">
		<b>Enviar un nuevo archivo: </b>
		<br>
		<input name="userfile" type="file">
		<br>
		<input type="submit" value="Enviar">
	</form>
</body>
</html>
Código PHP

Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Subiendo una nueva foto</title>
	<link rel="STYLESHEET" type="text/css" href="estilos_admin.css">
</head>

<body>
<h1>Subiendo un archivo</h1>
<br> 
<div align="center">
<?
//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, "jpg")) && ($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']['tmp_name'],  $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>

Anticipadamente gracias!!

Que tengan un buen día!!!