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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:45:28+00:00 2026-05-21T07:45:28+00:00

A PHP application is offering binary data as a download: header(Content-Type: application/octet-stream); header(Pragma: public);

  • 0

A PHP application is offering binary data as a download:

header("Content-Type: application/octet-stream");       
header("Pragma: public");
header("Cache-Control: private");   
header("Content-Disposition: attachment; filename=\"$filename\"");
header("expires: 0");      
set_time_limit(0);
ob_clean();
flush();    
@readfile($completefilename); exit;

$completefilename is a stream like “ftp://user:pwd@…”

The size of the data can be several MByte. It works fine, but sporadically I get the following error:

Error

  • 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-05-21T07:45:29+00:00Added an answer on May 21, 2026 at 7:45 am

    It’s most likely that the remote stream is occasionally down, or times out.

    Also as @fab says it could be that the file you are trying to load is larger than your script’s memory.

    You should start logging the errors readfile() returns, e.g. using the error_log php.ini directive.

    If this needs to be completely foolproof, I think you’ll have to use something more refined than readfile() that allows to set a timeout (like curl, or readfile with stream context options).

    You could then catch any errors that occur while downloading, and serve a locally hosted fallback document instead. That document could e.g. be a text file containing the message “Resource xyz could not be loaded”.

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

Sidebar

Related Questions

I have a Php application using stream_socket_client(), to get data through tcp from a
I have a PHP application that displays a list of options to a user.
Situation: A PHP application with multiple installable modules creates a new table in database
When a PHP application makes a database connection it of course generally needs to
I wrote a small PHP application several months ago that uses the WordPress XMLRPC
I am planning a PHP application that needs to store date/times in an MSSQL
I've got a PHP application which needs to grab the contents from another web
I wrote a small PHP application that I'd like to distribute. I'm looking for
I am building a PHP application in CodeIgniter. CodeIgniter sends all requests to the
In a PHP application I am writing, I would like to have users enter

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.