0

So Right now I use below code , But If the external file is like 100mb It takes forever for the download to be prompted.How can I prompt download immediately and start streaming download to users.

 <?php
    header( 'Content-Type: application/x-bittorrent' );
    header( 'Content-Disposition: attachment; filename="torrent' );
    echo file_get_contents("http://externallink.com/sizemorethan100mb");
    ?>

EDIT : its not duplicate , duplicated question does not provide solution for external url.

  • possible duplicate of [Streaming a large file using PHP](http://stackoverflow.com/questions/6914912/streaming-a-large-file-using-php) – showdev Jun 04 '15 at 16:10
  • I have seen that question , there is no answer for external file...they just answered for local file. – pradap vishwa Jun 04 '15 at 16:12
  • The [`fpassthru()` method](http://stackoverflow.com/questions/6914912/streaming-a-large-file-using-php#answer-26784775) doesn't work? `fopen()` can open external URLs, so I assumed it would work. – showdev Jun 04 '15 at 16:17
  • It works for me. What errors do you get? What is the external URL? – showdev Jun 04 '15 at 16:40
  • Call to undefined function finfo_open() – pradap vishwa Jun 04 '15 at 16:41
  • That's a [separate issue](http://stackoverflow.com/questions/3579072/php-fileinfo-is-undefined-function). Try removing those lines and hard-coding the mime type. – showdev Jun 04 '15 at 16:43
  • You should try to open a file stream, and read portions of the file. Then flush oartions of the file to the user. See http://php.net/manual/en/function.stream-get-contents.php – Ruben Jun 04 '15 at 18:32

0 Answers0