phntje Posted February 15, 2008 Share Posted February 15, 2008 <?php $link = "http://host.com/link.rar"; $baselink = basename($link); $time = time(); $date = date("D, d M Y H:i:s \G\M\T" , $time); header("Content-Disposition: attachment; filename=$baselink"); header('Expires: '.gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y"))).' GMT'); header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream"); header("Accept-Ranges: bytes"); $sizeheaders = get_headers($link, 1); $size = $sizeheaders["Content-Len gth"]; if(isset($_SERVER['HTTP_RANGE'])) { list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']); //if yes, download missing part str_replace($range, "-", $range); $size2=$size; $new_length=$size2-$range; header("HTTP/1.1 206 Partial Content"); header("Status: 206 Partial Content"); header("Content-Le ngth: $new_length"); header("Content-Range: bytes $range$size2/$size"); } else { $size2=$size; //header("Content-Range: bytes 0-$size2/$size"); header("Content-Le ngth: ".$size2); } @readfile($link); ?> Downloading in firefox & other browsers is okay. But when using downloadmanagers, then its downloading the file but the file is corrupt, it's 1 or 2 bytes bigger then the original file. How to fix this? Link to comment https://forums.phpfreaks.com/topic/91327-resume-downloads-with-download-managers-headers/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.