Ver Mensaje Individual
  #9 (permalink)  
Antiguo 16/09/2008, 07:51
Avatar de hoberwilly
hoberwilly
 
Fecha de Ingreso: julio-2008
Ubicación: Lima - Perú
Mensajes: 769
Antigüedad: 15 años, 9 meses
Puntos: 2
Respuesta: Mostrar imagen, que esta guardado en servidor

Hola Carxl,
A ver este es el codigo que sube las imagenes en una carpeta fotografias en el servidor (www/fotografias) y en la bd guarda la ruta(oka):
subirImagen.php
----------------------
<!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
if($enviar)
{
include('conec.php');
conectarse();
if (is_uploaded_file($_FILES['nomimg']['tmp_name'])) {
if ($_FILES['nomimg']['type'] == "image/jpeg" || $_FILES['nomimg']['type'] == "image/pjpeg" || $_FILES['nomimg']['type'] == "image/JPG")
{
$nuevoNombre = time().".jpg";
move_uploaded_file($_FILES['nomimg']['tmp_name'], "fotografias/$nuevoNombre");
$ruta = "fotografias/$nuevoNombre";
chmod($ruta, 0777);
$contenido = stripslashes($_POST['contenido']);
$contenido = strip_tags($contenido);
$titulo = $_POST["titulo"];
$mensaje = $_POST["mensaje"];
mysql_query("INSERT INTO noticias (nomimg,contenido,titulo) VALUES('".$ruta."','".$_POST[contenido]."','$titulo')") or die('MySQL error: '.mysql_error());
echo "imagen $nuevoNombre subida con éxito";
}
else{
echo "Formato no válido para fichero de imagen";
}
}else{
echo "Error al cargar imagen: ".$_FILES['nomimg']['name'];
}
}
else{
?>
<form enctype="multipart/form-data" action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input name="nomimg" type="file" /><br />
Comentario:<br />
<textarea name="contenido" cols="50" rows="5"></textarea><br />
<input type="text" size="50" maxlength="45" id="titulo" name="titulo"><br />
<input type="submit" name="enviar" value="Subir Fichero" />
</form>
<?php
}
?>
</body>
</html>

y este es el codigo el cual muestra la noticia con su respectiva imagen:
noticia.php
---------------
<?
if(!isset($_GET['idNoticia']) || empty($_GET['idNoticia'])){
header("location:listaNoticia.php");
}
else{
include('conec.php');
conectarse();
$query = mysql_query("SELECT * FROM noticias WHERE idNoticia = '".$_GET['idNoticia']."'") or die('MySQL error: '.mysql_error());

while($row = mysql_fetch_array($query)){
echo "<h3>".$row['titulo']."</h3>".$row['mensaje'];
}
}
?>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><img src="<?=$row['nomimg']?>"></td>
</tr>
</table>

El problema como mencione es que muestra el titulo y el mensaje de la noticia pero no logro mostrar la imagen con <img>?????? ...solo me sale una aspa

Agradesco de antemano la ayuda que me puedas brindar