Código PHP:
<form action=<?=$PHP_SELF ?> method="post" enctype="multipart/form-data"/>
<p class="Estilo1">
<label></label>
</p>
<table width="316" height="66" border="0">
<tr>
<td width="87" height="34"><span class="Estilo1">Subir Foto :</span></td>
<td width="201"><input name="fichero" type="file" /></td>
</tr><tr>
<td height="26" colspan="2"><input name="submit" type="submit" value="Subir" /></td>
</tr>
</table>
<p><?php $link=mysql_connect("localhost","root","pass");
mysql_select_db("sistema_de_noticias",$link);
if (isset($_POST['submit'])){
if (is_uploaded_file($_FILES['fichero']['tmp_name'])){// verifico que haya sido cargado el archivo
$ruta= "foto/".$_FILES['fichero']['name'];
if(move_uploaded_file($_FILES['fichero']['tmp_name'],$ruta)){ //se coloca en su lugar final
mysql_query("INSERT INTO imagenes (ruta) values ('$ruta')",$link)or die (mysql_error());
}
}
}
?>
<?php
$link=mysql_connect("localhost","root","pass");
mysql_select_db("sistema_de_noticias",$link);
$result=mysql_query("SELECT * FROM imagenes ",$link);
$row = mysql_fetch_array($result) or die (mysql_error());
print_r($row);
?>
</p>
<p> <? echo "<img src='foto/$row[ruta]'>"; ?>
Array ( [0] => 72 [id_foto] => 72 [1] => foto/presentacion.jpg [ruta] => foto/presentacion.jpg )