Search the Community
Showing results for tags 'download php'.
-
I'm using the following code for users to download files from my website. It works fine for files under 50MB, but fails immediately for larger files. Can someone explain why this is happening and how to fix it? Some of the downloadable files are over 800MB, so I need this working. NOTE: No error messages are thrown on large files. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $php_scripts = '../../php/'; require $php_scripts . 'PDO_Connection_Select.php'; require $php_scripts . 'GetUserIpAddr.php'; $ip = GetUserIpAddr(); if (!$pdo = PDOConnect("foxclone_data")) { echo "unable to connect"; exit; } function mydloader($l_filename=NULL){ if( isset( $l_filename ) ) { $filename = preg_replace("/\s+/u", " ", $l_filename); $ext = pathinfo($filename, PATHINFO_EXTENSION); if ($ext == '.deb') header('Content-Type: octet-stream'); elseif ($ext == '.iso') header('Content-Type: application/x-cd-image'); elseif ($ext =='.gz') header('Content-Type: application/zip'); else header('Content-Type: octet-stream'); header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename={$filename}"); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($filename)); readfile($filename); // Get lookup id $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); // Insert record in download table $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"]); Thanks in advance
-
I've recently installed this script and have had no problems with Windows, Linux and most Mac downloads. However I've just discovered that Macs running the new Mountain Lion 10.8.x Mac OS X are getting time-outs. The script stalls if the ZIP file is more than about 52Mb (not sure of the exact cut-off). My Mac running Snow Leopard (10.6. works fine as do other people's Mac if they're not on Mountain Lion. Does anyone have any (a) ideas why? and (B) solutions? I'm not averse to replacing the whole script but this is the only one I've found that actually works with large ZIP files at all. The website I'm running the script on is a Windows server hosted by FastHosts. The script... http://www.richnetapps.com/php-download-script-with-resume-option/