I am writing a script that serves users downloads using my Megaupload premium account. This is the method that I'm using to download the Megaupload files:
public function download_file($link)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "/cookies/megaupload.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
return curl_exec($ch);
curl_close($ch);
}
And this is how it's being called in index.php:
readfile($megaupload->download_file("http://www.megaupload.com/?d=PXNDZQHM"));
What I basically want this to do is serve the download to the user and stream the download through my server. I do not want the file to be saved to my server and then offered to the user.
But obviously, the solution above won't work. I get this error:
Warning: readfile() [function.readfile]: Filename cannot be empty in C:\xampp\htdocs\index.php on line 8
I need to use cURL for this because I need to request the download using a cookie file (/cookies/megaupload.txt).
Can anyone think of a working way to do this? Cheers.