php - Download a file from mysql result which is on the web page -
my problem download file (any extension) clicking download icon, have tried print statement open new window , displaying, user can print entire web page , need give them download single file query. idea ??
this how query displaying , when user click on image should able download
doc_id passport_no photo nic_copy passport_copy 200004 n8899999 1376630109.jpg 1376630110.jpg 1376630111.jpg and coding ..
<?php if (isset($_get['file'])) { $file = $_get['file']; if (file_exists($file) && is_readable($file) && preg_match('/\.pdf$/',$file)) { header('content-type: application/pdf'); header("content-disposition: attachment; filename=\"$file\""); readfile($file); } } else { header("http/1.0 404 not found"); echo "<h1>error 404: file not found: <br /><em>$file</em></h1>"; } ?> a download link
<a href="http://localhost/visa/view.php?file=example.pdf">click here download pdf</a>
<a href="view.php?file=<?php echo $row['filename']; ?>">click here download pdf</a> view.php <?php $f="upload/".$_request['file']; // upload destination folder uploading files if(file_exists($f)) { header('content-description: file transfer'); header('content-type: application/pdf'); header('content-disposition: attachment; filename='.basename($f)); header('content-transfer-encoding: binary'); header('expires: 0'); header('cache-control: must-revalidate'); header('pragma: public'); header('content-length: ' . filesize($f)); ob_clean(); flush(); readfile($f); exit; ?>
Comments
Post a Comment