----- Original Message ----- From: "zari lahr" Dear sir..
this is what i am working out.... ============================================================== <snip> <td width="41%"><img src="images/<? echo $r["image_path"]?>" /></td> <snip> ============================================================ one thing that i have just stored the image name in mysql and store the all image in a saperate folder name images..as shown in the code above.. i want that when i click the download button the download box open and the image start to download. regards --------------------------------------------------------------------------- <td width="41%"> <a href="download.php?img=<?php echo($r['image_path']); ?>"> <img src="images/<? echo $r["image_path"]?>" /> </a> </td> download.php ... <?php if(isset($_GET['img'])) { if(download_img($_GET['img'])) { die(); } } function download_img($image_filename) { $path_parts = pathinfo($image_filename); $dirname = $path_parts['dirname']; if(($dirname != "") && ($dirname != ".")) return FALSE; // the image must have no path info aprt from above $ext = $path_parts['extension']; $permitted = "jpg jpeg png gif bmp"; $permitted = explode(" ", $permitted); foreach($permitted as $this_ext) { if($ext = $this_ext) { return output_img($path_parts['basename']); } } return FALSE; } function output_img($filename) { if(!file_exists("images/" . $filename)) // hard code the path information so that this // script can't be used to access other folders { //echo("[" . $filename . "] Does not exist<br>\n"); return FALSE; } if(!is_readable("images/" . $filename)) { //echo("[" . $filename . "] Is not readable<br>\n"); return FALSE; } header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header("Content-Type: application/octet-stream"); header("Content-Length: " . filesize($filename)); header('Content-Disposition: attachment; filename="' . $filename . '"'); header("Content-Transfer-Encoding: binary\n"); readfile("images/" . $filename); return TRUE; } ?> <b>Hacking not permitted</b> etc.... Also note that this script can be placed ate the beging if the script that generated the image selection page so that the pinter can be ... <td width="41%"> <a href="<?php echo($_SERVER['PHP_SELF']); ?>?img=<?php echo($r['image_path']); ?>"> <img src="images/<? echo $r["image_path"]?>" /> </a> </td>