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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:08:10+00:00 2026-06-06T07:08:10+00:00

This was working last night, but I must have accidentally changed something, because it

  • 0

This was working last night, but I must have accidentally changed something, because it isn’t now.

What I am trying to do should be clear from these headers:

Content-Disposition: attachment;filename=english_customizable.xml
Location: http://tortoisewrath.com/files/2.xml

However, when this header is sent, the Content-Disposition part doesn’t work after the redirect.

…Why?

  • 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-06T07:08:13+00:00Added an answer on June 6, 2026 at 7:08 am

    What you’re trying to do is inadvisable check this question; Header Location + Content Disposition

    Content-Disposition + Location header

    But you can do it, to make it work you will have to buffer your whole response before sending it. You can do this with output buffering

    • http://php.net/manual/en/book.outcontrol.php

    Else the browser may interpret the Location header before the file is downloaded. It’s sketchy either way, so you shouldn’t want to do this.

    Please note that forcing ‘save as’ using Content-Disposition: attachment; will make sure the client doesn’t go/navigate anywhere, so the method below on its own should be fine in any case.

    Streaming a file in php

    To just quote a guy who has his brains in the right place:

    // To use header() with 'content-type', why don't you use mime_content_type() function rather than checking the type on the basis of extension? 
    // Example code: 
    
    <?php 
    $file="test.docx"; 
    header("Pragma: public"); 
    header('Content-disposition: attachment; filename='.$file); 
    header("Content-type: ".mime_content_type($file)); 
    header('Content-Encoding: identity'); 
    ob_clean(); 
    flush(); 
    readfile($file); 
    ?> 
    
    // Use $file to map to whichever type of file. 
    // Note: the mime types should already be defined in apache settings
    

    Source: http://www.php.net/manual/en/function.header.php#107581

    Note that the original answer used Content-Transfer-Encoding which doesn’t actually exist in HTTP. The comment below that source explains it: http://www.php.net/manual/en/function.header.php#107044

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

Sidebar

Related Questions

So, thought I had this working last night, couldve sworn it. Now it no
i have been working on this sub-menu for 8 hours now, the last little
This code have been working until I updated last night. The code works perfectly
Actually I am working on this for the last 3 or 4 weeks but
I swear this was working last night which was why I was able to
I have this login code, which works last night before I slept. Nobody used
Up until updating Xcode last night, this was working great (though probably through sheer
i got this code working and it to return the last tweet from my
I do not get the last version of node-http-proxy working (this used to work
This is the last part of the program I am working on. I want

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.