I have two large files that I want to make available for users to download. When trying to download from my web host, the download never starts and I get a "504 Gateway Timeout". How would I revise my code to download from a file sharing site? I tried the following code but get a "This page isn’t workingfoxclone is currently unable to handle this request."

Appreciate any help you can provide.

<?php

function mydloader($l_filename=NULL) {

    $php_scripts = '../../php/';
    require $php_scripts . 'PDO_Connection_Select.php';
    require $php_scripts . 'GetUserIpAddr.php';

    if( isset( $l_filename ) ) { 

       if substr($l_filename, 0, 10)=='foxclone_s' {
            $url_path = 'https://www.mediafire.com/file/tyqr4tzthiftuy1/foxclone_std-50-06.iso/file' }
       elseif substr($l_filename, 0, 10)=='foxclone_e' {
          $url_path = 'https://www.mediafire.com/file/xnovs5ltdj2z5wr/foxclone_edge-50-07.iso/file'  }
      else

              header('Content-Type: application/octet-stream');
              header("Content-Transfer-Encoding: Binary"); 
              header("Content-disposition: attachment"); 
              header('Pragma: no-cache');
              header('Expires: 0');       
              readfile($l_filename);
    }


        $ip = GetUserIpAddr();
        if (!$pdo = PDOConnect("foxclone_data"))
        {   echo "unable to connect";
            exit;
        }


        $test = $pdo->query("SELECT lookup.id FROM lookup WHERE inet_aton('$ip') >= lookup.ipstart AND inet_aton('$ip') <= lookup.ipend");
        $ref = $test->fetchColumn();
        $ref = intval($ref);

        $ext = pathinfo($l_filename, PATHINFO_EXTENSION);
        $stmt = $pdo->prepare("INSERT INTO download (address, filename, ip_address, lookup_id) VALUES (?, ?, inet_aton('$ip'), ?)");
        $stmt->execute([$ip, $ext, $ref ]) ; 

       }

    else {
        echo "isset failed";
        }  
}
mydloader($_GET["f"]);

All the sites I've seen use Mediafire supply a link to the file and we end up on the Mediafire site to complete the download. Why this is, is likely because Mediafire is ad supported and more. I'm guessing you want to bypass all that and hide the URL of the actual download. But I could be wrong.

Also, when I tried the URL from line 14 Mediafire coughed up errors. Such as "This file is currently set to private." so not only do you have to research if what you are asking is possible but would have to login to Mediafire via PHP or such.

In other words, Mediafire for what I'm guessing you are trying to do looks like a dead end. But if you want to present a page with the download link, Mediafire is fine here.

@rproffitt - Your assumption near the end of your first paragraph is correct. I want to hide the URL of the actual download

Given you are creating your own up/downloader all I can offer is that Mediafire looks like a dead end as well, reasons.

I see from your other discussion you were trying the single line of PHP to send the file and that fails for the reasons Dani and maybe others noted.

So what to do but write your own up/downloader. It will have to read and send in chunks like we see at https://www.tutorialspoint.com/how-to-download-large-files-through-php-script Sorry but I can't write this for you.

My web host made some adjustments to my account. The downloads of the large files now works correctly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.