Código PHP:
<?php
if ($_POST['activa']=="activa"){
$code=$_POST['code_id'];
$code= str_replace("imagenes/","",$code);
include ('conexion_glo.php');
$conexioncha = mysql_connect($host, $user, $passcha);
mysql_select_db($bd, $conexioncha);
$quien = mysql_query("SELECT * FROM saprites WHERE codigo='$code'") or die(mysql_error());
$imag = mysql_fetch_array($quien);
$id_imag=$imag['nombre'];
$id_imag =str_replace(" ","_",$id_imag);
$enlace ="imagenes/imagenes/".$imag['codigo'];
header ("Content-Disposition: attachment; filename=".$id_imag);
header ("Content-Length: ".file($enlace));
readfile($enlace);
mysql_close();
}
?>