Still corrupt. I've gone for a different solution, not ideal but i don't have much more time to work on this. Means to an end.
PHP Code:
<?php
class Download {
public $path = NULL;
public $contentType = NULL;
public $contentDisposition = NULL;
function __construct($path, $filename) {
$this->path = $path;
$this->filename = $filename;
$this->contentType = mime_content_type($path);#$contentType;
$this->contentDisposition = "attachment";#$contentDisposition;
}
public function Exists() {
if (file_exists($this->path)) {
return true;
} else {
return false;
}
}
public function Size() {
if ($this->Exists()) {
return filesize($this->path);
} else {
return false;
}
}
public function Permit_Other() {
return substr(decoct(fileperms($this->path)), -1);
}
public function Init() {
if ($this->Exists() && $this->Permit_Other() >= 4) {
if (ereg ("^image", $this->contentType)) {
echo '<img src="'.SITE_URL.$this->path.'" alt="" title="" />';
exit();
} else {
ob_start();
header("Cache-Control: public, must-revalidate");
header("Pragma: no-cache");
header("Content-Description: File Transfer");
header('Last-Modified: '.date('r'));
header('Content-Type: '.$this->contentType);
header('Content-Disposition: '.$this->contentDisposition.'; filename="'.$this->filename.'"');
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$this->Size());
readfile($this->path);
ob_flush();
exit();
}
} else {
return false;
}
}
}
?>
Bookmarks