Need help - php download from remote URL

On my website, I have a download folder containing several files ranging in size from 6Mb to 700Mb. Users have no problems downloading the smaller files but often have problems downloading the files over 500Mb. We also have an archive of all the files located on a sub-domain on a server in England. Those users that are having problems downloading large files from the main U.S. site usually have no problem downloading the large files if we send them the URL for the archive. I’ve added a button that calls the following script so the users can choose where to download from but have no idea how to code the script.

Here’s what I’ve tried:

// ukdloader script

$php_scripts = '../../php/';
require $php_scripts . 'PDO_Connection_Select.php';
require $php_scripts . 'GetUserIpAddr.php';
function ukdloader($l_filename=NULL)

$ip = GetUserIpAddr();
if (!$pdo = PDOConnect("foxclone_data"))

    if( isset( $l_filename ) ) {  
        echo <a href="".$l_filename">   /* This is the archive site */
        $ext = pathinfo($l_filename, PATHINFO_EXTENSION);
        $stmt = $pdo->prepare("INSERT INTO download (address, filename,ip_address) VALUES (?, ?, inet_aton('$ip'))");
        $stmt->execute([$ip, $ext]) ; 

        $test = $pdo->query("SELECT id FROM lookup WHERE INET_ATON('$ip') BETWEEN start AND end ORDER BY start DESC, end DESC");
        $ref = $test->fetchColumn();
        $ref = intval($ref);

        $stmt = $pdo->prepare("UPDATE download SET ref = '$ref' WHERE address = '$ip'");
        $stmt->execute() ;         
    else {
        echo "isset failed";

Thanks in advance

I was going thru question with zero replies to see if I can help I found this one. I think nobody replied because we are not sure what you are asking. I have a few servers set up and more than one of them have very large files on them. Some are 3GB’s. So, 5MB to 700MB should not be an issue.

Well, usually a download is just an ANCHOR tag, nothing more. And, that is easy to code. If you mean you want to download a file from a remote site using PHP on someones else’s computer, just use the builtin function for that. Here is an example of getting the page you talked about:

$URL = "".$l_filename
$page = file_get_contents($URL);

You would get this page into a variable. Then, you need to save it locally as needed. Is this what your question is about?

EDIT: You may have issues with CROSS-DOMAIN errors if your site needs special access permissions. If that is so, then you would need to use cURL to add user ID’s and passwords.

Sponsor our Newsletter | Privacy Policy | Terms of Service