Quick file download hack

Permalink
Hey all - this is related to the discussion at:http://www.concrete5.org/community/forums/chat/help_file_downloads_...

Can anyone help with a quick workaround? Basically click on a file link and instead of streaming, simply forward to the file? I'm currently combing through the code but it may take me a while.

Thanks,
Corey

jizzle
 
jizzle replied on at Permalink Reply
jizzle
Ok, finally got it. It's rigged right now though. Posting in case anyone else has a problem with the streaming file downloads.

In /controllers/download_file.php, change
private function download($file) {
      //$mime_type = finfo_file(DIR_FILES_UPLOADED."/".$filename);
      //header('Content-type: $mime_type');
      // everything else lets just download
      $filename = $file->getFilename();
      $file->trackDownload();
      $ci = Loader::helper('file');
      $ci->forceDownload($file->getPath());      
   }


to
private function download($file) {
$newpath = "YOURDOMAINHERE.com" . $file->getRelativePath();
header("Location: $newpath");
}
pepearaya replied on at Permalink Reply
hi, you can use DIR_REL instead of write the entire URL or domain to call the base url.

$newpath = DIR_REL . $file->getRelativePath();

tested and it works!