Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. if(file_exists($myfile))
  2. {
  3. // Add bellow code for mime type
  4. $temp = explode(".",$myfile);
  5. $ext = strtolower(end($temp));
  6. $mime_types = array(
  7.  
  8. // video
  9. '3gp' => 'video/3gpp',
  10. '3g2' => 'video/3g2',
  11. 'avi' => 'video/avi',
  12. 'mp4' => 'video/mp4',
  13. 'asf' => 'video/asf',
  14. 'mov' => 'video/quicktime',
  15. );
  16. if (array_key_exists($ext, $mime_types)){
  17. $mm_type=$mime_types[$ext];
  18. }else{
  19. $mm_type="application/octet-stream";
  20. }
  21. $fname=str_replace(" ","_",$result->TITLE);
  22. //header("Cache-Control: public, must-revalidate");
  23. header("Pragma: public");
  24.  
  25. header("Content-Type: ".$mm_type);
  26.  
  27. header('Content-Disposition: attachment; filename='.$fname);
  28. header('Content-Length: '.filesize($myfile));
  29. header("Content-Transfer-Encoding: binary");
  30. ob_clean();
  31. flush();
  32. readfile($myfile);
  33. }
  34. else
  35. {
  36. echo "unable to download";
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement