Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5942849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:18:41+00:00 2026-05-22T16:18:41+00:00

I am writing a script that serves users downloads using my Megaupload premium account.

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:18:42+00:00Added an answer on May 22, 2026 at 4:18 pm

    Yes, exactly as it says, readfile expects a filename, and you’re giving it a string of the curl result. Just use echo after setting the proper headers:

    echo $megaupload->download_file("http://www.megaupload.com/?d=PXNDZQHM");
    

    EDIT: Also you need to do some basic checks that you got something back:

    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);
        $result = curl_exec($ch);
        // close before you return
        curl_close($ch);
        return $result;
    }
    

    Then:

    $filecontents = $megaupload->download_file("http://www.megaupload.com/?d=PXNDZQHM");
    if($filecontents) {
      echo $filecontents;
    }
    else {
      die("Yikes, nothing here!");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a PHP script that downloads a series of generated files (using wget
I'm writing a script that is supposed to run around a bunch of servers
I'm writing a script that has to move some file around, but unfortunately it
I am writing a script that will look in a custom reports directory, copy
I am writing a script that checks if given domain is parked or not.
I'm writing a script that will ping my ip range. Here's what I have
I'm writing a script that'll read through my ftpd logs and generate a hash
I'm writing a script that parses the pure-ftpwho -s command to get a list
I am writing a script that is retrieving information from file places.sqlite (history) and
I was writing a script that kept giving me errors. After tracking it down

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.