Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/07/2012, 08:33
ctpe_coordinador
 
Fecha de Ingreso: julio-2012
Mensajes: 3
Antigüedad: 11 años, 9 meses
Puntos: 0
Respuesta: Scripts para subir imágenes con PHP

En este código me sube la imagen a una carpeta y me la muestra pero no lo hace a la base de datos. Me gustaría que me indicara cuál es el error que estoy cometiendo, gracias




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body><?php

$conexion = mysql_connect("localhost", "root");
mysql_select_db("real_estate", $conexion);


if (isset($_POST['submit'])) {
if(is_uploaded_file($_FILES['fichero']['tmp_name'])) { // verifica haya sido cargado el archivo
if(move_uploaded_file($_FILES['fichero']['tmp_name'],"imagenes/". $_FILES['fichero']['name'])) { // se coloca en su lugar final
echo "<b>Upload exitoso!. Datos:</b><br>";
echo "Nombre: <i><a href=\"".$_FILES['fichero']['name']."\">".$_FILES['fichero']['name']."</a></i><br>";
echo "Tipo MIME: <i>".$_FILES['fichero']['type']."</i><br>";
echo "Peso: <i>".$_FILES['fichero']['size']." bytes</i><br>";
echo "<br><hr><br>";
}
}


}

$nom="imagenes/". $_FILES['fichero']['name'];
echo "<img src=\"$nom\">";






mysql_query("INSERT INTO archivos (fichero) VALUES ('$nom')");

?>
// A continuación el formulario

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data">
Archivo: <input name="fichero" type="file">
<input name="submit" type="submit" value="Upload!">
</form>
</body>
</html>