Advertisement
gamamuhammad

proses.php

Jan 17th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2. include "../include/koneksi_db.php";
  3. mysql_close($konek);
  4. $date=date('d-m-Y-g-i-s');
  5. $file="backup@".$date.".sql";
  6. $command = "mysqldump -u root db_perpus > backup/$file";
  7. $backup=exec($command);
  8. // header yang menunjukkan nama file yang akan didownload
  9.     header("Content-Disposition: attachment; filename=$file");
  10.  
  11.     // header yang menunjukkan ukuran file yang akan didownload
  12.     header("Content-length: $file ");
  13.  
  14.     // header yang menunjukkan jenis file yang akan didownload
  15.     header("Content-type:$file ");
  16.  
  17.    // proses membaca isi file yang akan didownload dari folder 'data'
  18.    $fp  = fopen("backup/".$file, 'r');
  19.    $content = fread($fp, filesize('backup/'.$file));
  20.    fclose($fp);
  21.  
  22.    // menampilkan isi file yang akan didownload
  23.    echo $content;
  24. if ($backup) {
  25. echo "<script>alert('Berhasil Backup.Nama File = $file');</script>";
  26. } else {
  27. echo "<script>alert('Gagal Backup !');</script>";
  28. }  
  29. exit;
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement