Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "db.php";
- if(isset($_POST['download'])){
- $id = $_POST['id'];
- $query = "SELECT * FROM kind_of_requirement WHERE id = '$id'";
- $hasil = mysql_query($query);
- $data = mysql_fetch_array($hasil);
- // header yang menunjukkan nama file yang akan didownload
- $file ="helpdesk/file/".$data['name'];
- //cek jika file tidak ada
- if(!file_exists($file)){
- echo "file not found";
- }else{
- header("Pragma: public"); // required
- header("Expires: 0");
- // header yang menunjukkan jenis file yang akan didownload
- header("Content-type: ".$data['type']);
- header('Content-Description: File Transfer');
- header("Content-Transfer-Encoding: binary");
- header('Content-Length: ' . filesize($file));
- header('Content-Disposition: attachment; filename=' . basename($file));
- readfile($file);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement