Header("Content-Type: application/octet-stream") header("Content-Disposition: attachment filename=\".\"" ) Note that you cannot know the download size in this case. You also need to output the headers before the the passthru. The parameters makes youtube-dl output the downloaded video to its standard output, while the passthru passes the standard output to a browser. Then use the passthru PHP function to run the youtube-dl with the -o - command-line parameter. The youtube-dl.exe is a build for Windows, while most webhostings use Linux. How to directly start the download to user's browser?Īlso the file is running fine on localhost but not on remote server.įirst, you need to use a version of youtube-dl for a platform of your webserver. When I run this file the respective YouTube video is first downloaded to the localhost server folder where this PHP file is, using youtube-dl.exe and then it is pushed from that folder to browser download (forced download).
0 Comments
Leave a Reply. |