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

  • SEARCH
  • Home
  • 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 8822827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:12:14+00:00 2026-06-14T06:12:14+00:00

I am getting reports by some users that they can’t download files. This is

  • 0

I am getting reports by some users that they can’t download files.

This is the script inside the download counter file.

<?php
$id = $_GET['id'];
require('conn.php');
$stmt = write_conn()->prepare("UPDATE links SET dl_count = dl_count + 1 WHERE ID=" . $id);
$stmt->execute();
header('Location: ' . $row['mp3_url'] );
?>

I heard using Header() function for redirecting user to a download link has some limits and it doesn’t work well on IE. is that right ?

What’s the right way to do this ?

  • 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-14T06:12:15+00:00Added an answer on June 14, 2026 at 6:12 am

    After researching and trying a lot of test & trials, I found some facts about the header() function and readfile() or similar ones.

    1. First of all you should know that header() has compatibility issues with different browsers. So don’t try to look for a function that is flawless. The issue isn’t the php function, it’s the browsers that has different way of analyzing a download header so they all behave differently. And you may know already, the biggest troublemaker is IE

    2. If you want to fix the problem and make it work using header(), You’ll have to add/force some header details (Content-Type,etc) , But this is not possible in your php code. No matter how many times you try, it just doesn’t work that work. I don’t have much info on this, But I just know even if you add the Content-Type headers before the actual header() it won’t work. seems they are completely for different purposes.

    3. You can use add the necessary headers and use the readfile() function instead and it will work fine. But you should know that this function will load/read the file/url you’re calling into the memory. This could be a big problem and will probably slow down your webserver, The worst situation is that it could crash as well. This can happen if you have too downloaders or many files.

    Unfortunately, as I mentioned before, you can’t fix this in your php code. So what I did in order to fix this problem, was adding the headers in my webserver vhost.

    NginX:

    location ~ ^/.*\.mp3$ {
            add_header Pragma "public";
            add_header Expires "0";
            add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
            add_header Content-Disposition "attachment";
            add_header Content-Type "application/force-download";
            add_header Content-Type "application/octet-stream";
            add_header Content-Type "application/download";
            add_header Content-Transfer-Encoding "binary";
            }
    

    In my case, the files users had to download was in mp3 format. But you can change it or set a global directive so it can work with any format.

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

Sidebar

Related Questions

We are getting reports from a small number of users that they are ending
I'm getting crazy with this problem: I have got some Oracle SQL-Reports to redesign
I've been getting reports from some visitors of one of my web sites that
I'm getting sporadic reports of users seeing our website with the Comic Sans font.
I have an WPF application for 60 users tops. Some of they are cashier
I have a script that generates a temporary HTML file that has links to
I'm having reports and complaints from my user that they will be using a
I just released my first app for Android and I am getting reports that
We have some SSRS reports that are failing when two of them are executed
I'm getting quite a few OutOfMemoryError reports from my users and every single report

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.