Guest User

Untitled

a guest
Oct 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. if (isset($_GET['downloadfile'])) {
  2. $posts_id = $_GET['downloadfile'];
  3. $sql_app = $auth_user->runQuery("
  4. SELECT DISTINCTROW AA.post_id,
  5. BB.`meta_value` AS 'resume'
  6. FROM `wp_postmeta` AS AA
  7. LEFT OUTER JOIN `wp_postmeta` AS BB ON AA.post_id = BB.post_id
  8. AND BB.meta_key ='resume'
  9. WHERE AA.meta_key IN ('resume')
  10. AND AA.post_id=:posts_id
  11. GROUP BY AA.post_id
  12. ORDER BY AA.post_id DESC
  13. ");
  14. $sql_app->execute(array(":posts_id"=>$posts_id));
  15. $downRow=$sql_app->fetch(PDO::FETCH_ASSOC);
  16.  
  17. $filepath = $downRow['resume'];
  18. // Process download
  19. if(file_exists($filepath)) {
  20. header('Content-Description: File Transfer');
  21. header('Content-Type: application/octet-stream');
  22. header('Content-Disposition: attachment; filename="'.basename($filepath).'"');
  23. header('Expires: 0');
  24. header('Cache-Control: must-revalidate');
  25. header('Pragma: public');
  26. header('Content-Length: ' . filesize($filepath));
  27. flush();
  28. readfile($filepath);
  29. exit;
  30. }
  31. }
Add Comment
Please, Sign In to add comment