1. $filename = $_GET['file'];
  2. $ext = $_GET['type'];
  3. $filename .= '.' . $ext;
  4. $path = "../generatedReports/" . $filename;
  5. header('Content-type: application/vnd.ms-excel;');
  6. header('Content-Disposition: attachment; filename=' . $filename);
  7. header("Pragma: public");
  8. header("Expires: 0");
  9. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  10. header("Cache-Control: public", false);
  11. header("Content-Description: File Transfer");
  12. header("Accept-Ranges: bytes");
  13. header("Content-Transfer-Encoding: binary");
  14. header("Content-Length: " . filesize($path));
  15. $size = filesize($path);
  16. $f = fopen($path, 'r');
  17. $content = fread($f, $size);
  18. echo $content;
  19.  
  20. echo unicode2utf8(hexdec("00CE")); // Result: Î
  21.  
  22. // Or the function that will recognize U+ in front of string, and will skip it to show the character
  23. function unicodeCodePointToChar($str) {
  24. if (substr($str,0,2) != "U+") return $str;
  25. $str = substr($str,2); // Skip U+
  26. return unicode_to_utf8(array(hexdec($str)));
  27. }
  28. echo unicodeCodePointToChar("U+00CE"); // Result: Î
  29.  
  30. $filename = $_GET['file'];
  31. $ext = $_GET['type'];
  32. $filename .= '.' . $ext;
  33. $path = "../generatedReports/" . $filename;
  34. header('Content-type: application/vnd.ms-excel;');
  35. header('Content-Disposition: attachment; filename=' . $filename);
  36. header("Pragma: public");
  37. header("Expires: 0");
  38. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  39. header("Cache-Control: public", false);
  40. header("Content-Description: File Transfer");
  41. header("Accept-Ranges: bytes");
  42. header("Content-Transfer-Encoding: binary");
  43. ob_clean(); // discard any data in the output buffer (if possible)
  44. flush(); // flush headers (if pos
  45. readfile($path);