Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:24:51+00:00 2026-06-15T10:24:51+00:00

Whenever I use this script to download a file, I can’t see the total

  • 0

Whenever I use this script to download a file, I can’t see the total size and the speed while downloading… I want to to make it look more like the ‘direct download link’. The purpose of this script is to hide the direct download link restrict direct downloading and other download behavior, like bots. Think of mediafire, rapidshare, megaupload etc.

The script we have now works but is not displayed as how it is displayed when you download from a normal download link, I will post a screenshot of what’s happening:
enter image description here

I hope this screenshot helps, because I’ve searched the internet for hours and can’t seem to find a solution to this :(.

if (isset($_GET['file'])){
   $file = $_GET['file'];
   $path = '/home/user/domains/domain.com/files/upload/';
   $filepath = $path.$file;

   if (file_exists($filepath)){

    set_time_limit(0); // for slow connections

    header('Content-Description: File Transfer');
    header("Content-Disposition: attachment; filename=\"$file\"");
    header('Content-Type: application/octet-stream');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($filepath));
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Expires: 0');

    readfile($filepath); // send file to client 
   } 
   else{
    header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); 
   }
  }else{
   header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); 
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:24:52+00:00Added an answer on June 15, 2026 at 10:24 am

    Is the content being compressed at the server level with mod_deflate or something similar?

    This has been answered here:
    Sending correct file size with PHP download script

    “If you compress files with Zlib, mod_deflate and so on the Content-Length header won’t be accurate so you’ll end up seeing “Unknown size” and “Unknown time remaining” when downloading files.”

    “You can easily disable it for a single script using the following line in an applicable .htaccess file:

    SetEnvIfNoCase Request_URI ^/download.php no-gzip dont-vary
    where download.php is here assumed to be in the download script located in the server’s root directory path (e.g. http://www.crimsonbase.com/download.php). (That’s because the regular expression is ^/download.php.)”

    Also, please note that your script is insecure. Someone could effectively send the following get parameter for _GET[‘file’]

    ../../../../../Documents/MyStuff
    

    and it will override your $path restriction entirely.

    Suggest stripping out any .. references in the path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've always wondered this, and still haven't found the answer. Whenever we use cout
I have a JS script that changes content of webpages. I use this script
I'm trying to make this script for a forum, which allows the use of
I would like to set environmental variables in bash whenever I use a script
I tend to use it whenever I am working on a prototype script, and:
Whenever I use script/generate to generate a new scaffold for a change to my
Whenever I need to reference a common module or script, I like to use
I use ESS-Emacs to edit my R scripts. Whenever I load a R script
Whenever I use the Gethomepath function of Delphi I keep getting Shell Script Invocation
when ever i use window.location.href=//some url it always open a new window, this only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.