how to download the video using php script

后端 未结 2 407
再見小時候
再見小時候 2021-01-13 22:59

In my program I want to add a download option to download the currently straming video. I tried this code:

$psp = \"Tom_20_amp__20Jerry_20race-1.flv\";
heade         


        
2条回答
  •  广开言路
    2021-01-13 23:49

    Change you're header from :

    header("Content-type:application/octet-stream");
    

    To :

    header("Content-type: video/flv");
    

    Then you can do :

    header("Content-Disposition:attachment;filename=\"$psp\"");
    //allways a good idea to let the browser know how much data to expect
    header("Content-length: " . filesize($psp) . "\n\n"); 
    echo file_get_contents($psp); //$psp should contain the full path to the video
    

提交回复
热议问题