Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/05/2005, 01:30
bulldog
 
Fecha de Ingreso: enero-2003
Mensajes: 330
Antigüedad: 21 años, 3 meses
Puntos: 0
Pregunta subiendo imagen al servidor

Hola, estoy tratando de subir una imagen al servidor mediante un formulario, en la base de datos, mysql, sólo guardo la ruta. He seguido un código que puso hace un par de meses un miembro de este foro pero algo debo estar haciendo mal ya que luego no consigo mostrar la imagen, supongo que no estoy subiendo la imagen al servidor. Os pongo el codigo a ver si me podeis echar una mano:

Este es el formulario que tengo:

<form action="add.php" method="post" enctype="multipart/form-data" name="insertar">

Titulo de Noticia:
<input name="titulo" type="text" size="50">
Noticia:
<textarea name="noticia" cols="50" rows="7"></textarea>
<input type="hidden" name="MAX_FILE_SIZE" value="50000">
<input type="file" name="imagen"></p>
<input type="submit" name="Submit" value="Poner noticia">
<input type="reset" value="Restablecer">

</form>


En add.php:

Código PHP:
include ("conexion.php");
$titulo=$_POST['titulo'];
$noticia=$_POST['noticia'];
$fecha=date('Y-m-d');
$imagen=$_FILES['imagen']['name'];
    
$unico time();
$directorio $_SERVER['DOCUMENT_ROOT'].'/images/uploads/'.$unico
$imagen_path $directorio.$imagen;

mysql_query("INSERT INTO noticias (titulo,noticia,imagen,fecha) VALUES ('$titulo','$noticia','$imagen_path','$fecha')"); 
Un saludo