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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:40:41+00:00 2026-05-23T08:40:41+00:00

How to send the header to the client before execute the php scripts ?

  • 0

How to send the header to the client before execute the php scripts ?

My script take many time to finish and the client don’t receive anything through this period.

<?

header("HTTP/1.1 200 OK");
header("Date: Thu, 23 Jun 2011 10:16:31 GMT");
header("Content-Type: application/octet-stream");
header("Content-Length: 12275768");
header("Accept-Ranges: bytes");
header('Content-Disposition: attachment; filename="Untitled-1.bmp"');
header("Content-Transfer-Encoding: binary");
header("Connection: close");

//Send headers now

//because my php script take many time to finish
//because it downloads a file from a remote server

.
.
.

?>
  • 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-23T08:40:42+00:00Added an answer on May 23, 2026 at 8:40 am

    I’m not sure how passthru works and if the command’s output is buffered somehow. But here’s another example using fopen, a streaming context for the request header fields and the chunked transfer coding with an explicit flush:

    header("HTTP/1.1 200 OK");
    header("Date: Thu, 23 Jun 2011 10:16:31 GMT");
    header("Content-Type: application/octet-stream");
    header("Accept-Ranges: bytes");
    header('Content-Disposition: attachment; filename="Untitled-1.bmp"');
    header('Content-Transfer-Encoding: chunked');
    header("Connection: close");
    
    $opts = array(
      'http'=>array(
        'method'=>"GET",
        'header'=>"Accept-language: en\r\n" .
                  "Cookie: foo=bar\r\n"
      )
    );
    $context = stream_context_create($opts);
    $fp = fopen('http://www.example.com', 'r', false, $context);
    while (($buffer = fread($fp, 512)) !== false) {
        echo sprintf("%X", strlen($buffer)), "\r\n", $buffer, "\r\n";
        flush();
    }
    echo "0\r\n\r\n";
    flush();
    

    Make sure not to use ob_start or any other output buffering.

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

Sidebar

Related Questions

I have a client that wants to send a large number of SOAP Header
I'm using a Java socket, connected to a server. If I send a HEADER
Do web browsers send the file size in the http header when uploading a
How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header
I need to send and receive data over serial connections (RS-232 and RS-422). How
I am using MAMP (LAMP stack development environment) to send emails using PHP. The
To send a serial string character to the serial port. I would need to
I need to send hundreds of newsletters, but would like to check first if
Other than self.class.send :method, args... , of course. I'd like to make a rather
I want so send every week an update by email. But Im afraid that

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.