Código PHP:
<html>
<head>
<title>Fotos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="foto.php?id=<? echo $_GET[id];?>" method="post" enctype="multipart/form-data">
Foto<input type="file" name="imagen"><br>
<input type="submit" name="otra" value="Nueva Foto"><br>
<center><a href="editar.php">Volver</a></center>
<?php
$host="localhost";
$root="root";
$pass="";
$bd="inmobiliaria";
$con=mysql_connect($host,$root,$pass) or die (mysql_error());
mysql_select_db($bd,$con) or die (mysql_error());
$refe=$_GET[id];
$foto=$_FILES['imagen']['name'];
$foto_temp=$_FILES['imagen']['tmp_name'];
if($_POST[otra]){
$dir='imagenes/';
$dest= $dir . $foto;
if (copy($foto_temp,$dest))
{
$img="INSERT INTO imagenes(Foto,Referencia) VALUES('$dest','$refe')";
$r=mysql_query($img,$con) or die(mysql_error());
print "El archivo fue subido con éxito.";
}else{
print "Error al intentar subir el archivo.";
}
}
mysql_close($con);
?>
</form>
</body>
</html>