Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(file_exists($myfile))
- {
- // Add bellow code for mime type
- $temp = explode(".",$myfile);
- $ext = strtolower(end($temp));
- $mime_types = array(
- // video
- '3gp' => 'video/3gpp',
- '3g2' => 'video/3g2',
- 'avi' => 'video/avi',
- 'mp4' => 'video/mp4',
- 'asf' => 'video/asf',
- 'mov' => 'video/quicktime',
- );
- if (array_key_exists($ext, $mime_types)){
- $mm_type=$mime_types[$ext];
- }else{
- $mm_type="application/octet-stream";
- }
- $fname=str_replace(" ","_",$result->TITLE);
- //header("Cache-Control: public, must-revalidate");
- header("Pragma: public");
- header("Content-Type: ".$mm_type);
- header('Content-Disposition: attachment; filename='.$fname);
- header('Content-Length: '.filesize($myfile));
- header("Content-Transfer-Encoding: binary");
- ob_clean();
- flush();
- readfile($myfile);
- }
- else
- {
- echo "unable to download";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement