PHP Downloading a Huge Movie File (500 MB) with cURL -
okay, have problem hope can me fix.
i running server stores video files large, 650 mb. need user able request page , have download file machine. have tried everything, plain readfile() request hangs 90 seconds before quitting , gives me "no data received error 324 code," chunked readfile script have found several websites doesn't start download, ftp through php solutions did nothing give me errors when tried file, , curl solutions have found create file on server. not need.
to clear i need user able download file their computer , not server.
i don't know if code garbage or if needs tweak or two, appreciated!
<?php $fn = $_get["fn"]; echo $fn."<br/>"; $url = $fn; $path = "dl".$fn; $fp = fopen($path, 'w'); $ch = curl_init($url); curl_setopt($ch, curlopt_file, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); ?>
i wouldn't recommend serving large binary files using php or other scripting technology matter. never design -- can use apache, nginx or whatever standard http server have on end. if still need use php, should check out readfile_chunked.
http://php.net/readfile#48683 , here's great tutorial. http://teddy.fr/blog/how-serve-big-files-through-php
good luck.
Comments
Post a Comment