image is not stored in database... the path of the image is saved in the database and the respective image is displayed using that path address
ya you are righ .I saved path in database and image saved in folder on drive .. The code Which i used works very well but after the completion of download .. image preview is not present there ...... please suggest me good answer .....
hi thanx ... this is the code i am using below..... mainpage.php - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="stylenew.css" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Download Image</title> <script type="text/javascript" language="javascript" src="bank.js"> </script> </head> <body> <div class="header"> <?php include("header.php") ?> </div> <!------------> <div class="content"> <div class="content_resize"> <?php include('connect.php'); session_start(); $uid=$_SESSION['id']; $per_page = 3; $query='SELECT * FROM logic_image JOIN logic_bank ON logic_image.BankId=logic_bank.BankId WHERE logic_image.IsActive=1'; $result = mysql_query($query); $total_results = mysql_num_rows($result); $total_pages = ceil($total_results / $per_page); if (isset($_GET['page']) && is_numeric($_GET['page'])) { $show_page = $_GET['page']; if ($show_page > 0 && $show_page <= $total_pages) { $start = ($show_page -1) * $per_page; $end = $start + $per_page; } else { $start = 0; $end = $per_page; } } else { $start = 0; $end = $per_page; } if (!$result) { die("Query to show fields from table failed"); } if( $total_results==0) { echo "data not found"; } else {?> <table border='1px'> <tr> <th>Sr No.</th> <th>Client Name</th><th>Bank Name</th> <th>Description</th><th>Image</th><th> Uploaded Date</th><th>Download</th></tr> <?php for ($i = $start; $i < $end; $i++) { if ($i == $total_results) { break; } $a=$i+1; echo "<tr>"; echo '<td>'.$a.'</td>'; echo '<td>' . mysql_result($result, $i, 'ClientName') . '</td>'; echo '<td>' . mysql_result($result, $i, 'BankName') . '</td>'; echo '<td>' . mysql_result($result, $i, 'Description') . '</td>'; echo '<td>' . mysql_result($result, $i, 'image') . '</td>'; echo '<td>' . mysql_result($result, $i, 'UploadedDate') . '</td>'; //echo '<td><a href="'.mysql_result($result, $i, 'image').'"> Download</a></td>'; echo '<td><a href="downld2.php?id=' . mysql_result($result, $i, 'ImageId') . '&name='.mysql_result($result, $i, 'image').'">Download</a></td>'; echo "</tr>"; } ?> </table> <p align='center'> <?php for ($i = 1; $i <= $total_pages; $i++) { echo "<a href='download.php?page=$i'>$i</a> "; } echo "</p>"; } ?> <div class="clr"></div> </div> </div> <div id="footer"> <?php include("footer.php") ?> </div> </body> </html> downld2.php <?PHP $id=$_GET['id']; $im_name=$_GET['name']; //copy($id, '/tmp/file.jpeg'); //echo $id; include("connect.php"); $sql="SELECT image FROM logic_image WHERE ImageId=$id"; $result=mysql_query($sql); $row=mysql_fetch_array($result); $name=$row['image']; echo $name; $i = strrpos($name,"/"); //if (!$i) { return ""; } $l = strlen($name) - $i; $img = substr($name,$i+1,$l); //echo "<br>".$img; $download_path = $_SERVER['DOCUMENT_ROOT']."temp/image"; //echo "<br>".$download_path; //copy($im_name, $download_path."/$img"); /* ###################################################################################*/ /* DO NOT MODIFY THE SCRIPT BEYOND THIS POINT */ /* ###################################################################################*/ $filename =$img;// $_GET['filename']; echo $filename; // Detect missing filename if(!$filename) die("I'm sorry, you must specify a file name to download."); // Make sure we can't download files above the current directory location. if(eregi("\.\.", $filename)) die("I'm sorry, you may not download that file."); //$file =str_replace("..", "", $filename); // Make sure we can't download .ht control files. if(eregi("\.ht.+", $filename)) die("I'm sorry, you may not download that file."); // Combine the download path and the filename to create the full path to the file. $file = "$download_path/".$img; // Test to ensure that the file exists. if(!file_exists($file)) die("I'm sorry, the file doesn't seem to exist."); // Extract the type of file which will be sent to the browser as a header $type = filetype($file); //Get a date and timestamp $today = date("F j, Y, g:i a"); $time = time(); // Send file headers //header("Content-type: $type"); //header("Content-Disposition: attachment; filename=$img"); //header('Pragma: no-cache'); //header('Expires: 0'); //readfile($img); header('Pragma: public'); header('Cache-Control: public, no-cache'); header('Content-Type: application/octet-stream'); header('Content-Length: ' . filesize($file )); header('Content-Disposition: attachment; filename="' . basename($file ) . '"'); header('Content-Transfer-Encoding: binary'); readfile($file); // Send the file contents. //readfile($file); ?> This code works very well ..but after download completion when we open image to see the image there is no image preview present .After download it shows imageseze in kb ...also. thanx..