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 8547011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:10:11+00:00 2026-06-11T13:10:11+00:00

I am doing the follwoing on a web page: A click on an element

  • 0

I am doing the follwoing on a web page: A click on an element sends a set of data (attached to the element) to my server which will then generate a custom zip-file:

$.post(urlprefix + 'makeZip.php', params, function(data){
    window.location = urlprefix + 'getZip.php?file=' + data; //get file
}).error(handleAJAXError);

makeZip.php works just fine and returns the name of the (temporary) zip file that the client should then download. As I want to keep my server clean I route the file through another script called getZip.php which does the following:

/* RETURN REQUESTED FILE AND DELETE FROM SERVER*/
$filename = $_GET['file'];
/* TRANSFER FILE CONTENTS */
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="customDownload.zip"');
header('Content-Length: '.filesize($filename));
readfile($filename);
/* REMOVE FILE FROM SERVER */
unlink($filename);

All browsers will download the file successfully, yet I am facing one problem: the files can get rather big (up to 200MB) so I thought it would be nice to have an estimate of how long the download’s going to take. That’s why I am sending the Content-Length header (the specified filesize is correct). Yet, all browsers I tested this is are telling me the filesize is unknown (which might lead to the user skipping the download).

Is this some kind of problem with my header information? Is it a client-side problem? Should I use another approach to getting the client to download the file?

  • 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-11T13:10:12+00:00Added an answer on June 11, 2026 at 1:10 pm

    If the client shows “unknown filesize” in the dialog when downloading a file provided via readfile, you’d better check if mod_deflate, mod_gzip, mod_something-that-shrinks-http is installed on your server, and put an exception for given download.

    More info here

    EDIT by m90:

    In my particular case (running Apache) I turned shrinking off by using:

    @apache_setenv('no-gzip', 1);
    @ini_set('zlib.output_compression', 0);
    

    Filesize headers are sent and received correctly now in all browsers

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

Sidebar

Related Questions

While scrolling my web page a DIV which have a video is not going
In ASP.NET web forms, I would access the page class by doing the following:
I would like to have a button on a web page with the following
I am trying to build a db driven web site in which the user
So i'm dealing with an ASP.NET 4.0 Web Forms Application in which the DAL
On the web page, I get the following error: FieldError at /foo/bar/ Cannot resolve
I have a web page that is using JQuery to communicate with the backend.
In our application, we parse a web page and load it into another page
I want to put a player on a web page and I am using
I'm testing a web application using Selenium WebDriver and I was wondering which is

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.