Hi,
The way that I have always accomplished the download without leaving a page, and not "giving out" the image info, is using a two part process:
1, On the front end, I use a container that I fill in when either a button is clicked, or some other loading process. So in this instance I have a button that "onClick" goes to a javascript function called "download" which fills in the downloader div with a 1x1 iframe with a path to the "download page" and I pass a query string "i".
<input type="button" onClick="download()" />
<div id="downloader" style="height:1px; width:1px;"></div>
<script type="text/javascript">
function download(){
document.getElementById('downloader').innerHTML = '<iframe style="width:1px; height:1px; border:none;" src="/path/to/download.php?i=<?=$image?>"></iframe>';
}
</script>
Above I set the image variable to the image. You could alternatively use an ID or something else to "mask" the file name, then use some sort of sql statement to grab the image based on the information that you provide.
2, The "download" page (dowload.php) which is going to grab your "i" query string and start running your download process.
<?php
$image = $_GET['i'];
$path = $_SERVER['DOCUMENT_ROOT']."/path/to/image/".$image;
if ($fd = fopen ($path, "r")) {
$fsize = filesize($path);
$path_parts = pathinfo($path);
switch( $path_parts("extension") ) {
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
case "mp3": $ctype="audio/mpeg"; break;
case "wav": $ctype="audio/x-wav"; break;
case "mpeg":
case "mpg":
case "mpe": $ctype="video/mpeg"; break;
case "mov": $ctype="video/quicktime"; break;
case "avi": $ctype="video/x-msvideo"; break;
case "php":
case "htm":
case "html":
case "txt": die; break;
default: $ctype="application/force-download";
}
header("Content-type: $ctype");
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\"");
header("Content-length: $fsize");
header("Cache-control: private");
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
fclose ($fd);
}
exit;?>
So once you have these items in place, whether you are doing some sort of on load process or using php or simply adding the iframe into the "downloader" div when the page loads, the user will not be re-directed and you don't have to worry about getting them back to a certain page.
Kind of lengthy, but I hope this helps.
Cheers.