Shiva Tiwari

Shiva Tiwari

  • NA
  • 73
  • 5.2k

alert message is not displaying after downlading the file

May 30 2020 2:47 AM
  1. $select = "SELECT * FROM `success-stories` where id='$id'";  
  2. $result = $conn->query($select);  
  3. $row = $result->fetch_assoc();  
  4. $file=$row["download_pdf"];  
  5. $file_arr=explode("/",$file);  
  6. $path=$file_arr[0]."/".$file_arr[1]."/".$file_arr[2];  
  7. if(file_exists($path))  
  8. {  
  9. header('Content-Description: File Transfer');  
  10. header('Content-Type: application/pdf');  
  11. header('Content-Disposition: attachment; filename="'.$path.'"');  
  12. header('Expires: 0');  
  13. header('Cache-Control: must-revalidate');  
  14. header('Pragma: public');  
  15. header('Content-Length: ' . filesize($path));  
  16. ob_clean();  
  17. ob_flush();  
  18. readfile($path);  
  19. exit;  
  20. }  
  21. echo "<script>alert('Thank you for downloading story..');</script>";  

Answers (3)