1

I've some pdf files on my shared hosting server of bluehost. I need to download them from iOS app & I want to show the download progress bar.

But I couldn't because Content-length is not present in Header response.

How can I get this?

biplob
  • 1,252
  • 1
  • 11
  • 29
  • 1
    Reason is your gzip compression is enable. so you have to use alternative solution for : http://serverfault.com/questions/183843/content-length-not-sent-when-gzip-compression-enabled-in-apache http://stackoverflow.com/questions/815961/how-to-determine-the-content-length-of-a-gzipped-file – Chirag Shah Jul 31 '15 at 06:42
  • Can you please tell me, how can I disable this compression? I've searched my php.ini file with gzip but found nothing like that. But in response I'm getting >Content-Encoding gzip – biplob Jul 31 '15 at 06:54

1 Answers1

2

You can set it via header. With the header function you can set HTTP information. But note that you dont have any output before set HTTP informationen.

header('Content-type: application/pdf');
header("Content-length: $size");
header('Content-Disposition: attachment; filename="downloaded.pdf"');

Edit:

If you dont use PHP to download the file you can use SetEnv no-gzip dont-vary in your htaccess to suppress GZIP.

Tobias
  • 653
  • 4
  • 12
  • Thanks @Tobias. But the problem is I'm not requesting any php file. I'm requesting the pdf directly. – biplob Jul 31 '15 at 06:40
  • Ahh okay sorry. Try to add `SetEnv no-gzip dont-vary` in your htaccess. Because your server gzip the PDF file automatically. – Tobias Jul 31 '15 at 07:14