'ello all.
I am using HTTP_Download to simplify file downloading and to use throttling, resuming, etc ...
Problem is, I cannot seem to get files to download properly. They download all the way, but applications become corrupt. Images and plain text download fine.
I can access the files via FTP, download them and open them fine.
Here is the code I am using ... any insight as to what may be wrong would be great.
/** if file is zipped, change content type **/
preg_match("#^.*\.([A-Z0-9]+)$#i", $result['localname'], $matches);
$ext = strtolower($matches[1]);
if($ext == 'zip') $result['mimetype'] = 'application/zip';
/** guest file, let DL **/
$dl = new HTTP_Download();
$dl->setFile(PUB_DIR . DS . $result['localname']);
$dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, $result['outputname']);
/** if userID == 0 **/
if(isset($_SESSION['userid']) && $_SESSION['userid'] == 0){
$dl->setBufferSize(300 * 1024); // 300 KB
$dl->setThrottleDelay(1); // 1 sec
}
$dl->setContentType($result['mimetype']);
$dl->send();
Thanks!