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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:02:19+00:00 2026-05-27T10:02:19+00:00

I am currently developing an application in PHP in which my server (a dedicated

  • 0

I am currently developing an application in PHP in which my server (a dedicated server) must to download a file, and the user should download the file in same time.

Here is an example :

  • Server start to download a file at a time A.
  • User wants to download this file at the time A + 3 seconds (for example)

I already solved the problem :”If the user downloads the file faster than the server..“. But I didn’t know how to make a php script in which the user is gonna to download the full file (it means that the size must be the full size of the file, not the size it’s currently downloaded at the time A+3seconds). I already make that :

header('Content-Type: application/octet-stream'); 
header('Content-Disposition: attachment; filename="'.$data['name'].'";'); 
header('Content-Transfer-Encoding: binary'); 
header('Content-Length: '.$data['size']);
readfile($remoteFile);

But it doesn’t work, the user is gonna download just the size it is currently on the server (which corrupt the file) and not the full file…

If you have any solution, thank you.

  • 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-27T10:02:20+00:00Added an answer on May 27, 2026 at 10:02 am

    You could probably pipe the file manually, by opening the connection and reading until you’re past all headers. Then once you’ve figured out the Content-Length, send that to the user and just echo all remaining data you get (do use flush() and avoid output buffers).

    Pseudocode(-ish):

    open the file
    # grab headers
    while you didn't get all HTTP headers:
        read more
    look for the Content-Length header
    send the Content-Length header
    
    # grab the file
    while the rest of the request isn't done
        read more
        send it to the user
        flush the buffers
    
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing an application, which gets the input from a text file
I'm currently developing a PHP application that's using an Access database as a backend.
I am currently developing an application in where a user will dynamically choose dlls
I am currently developing an application which will require multiple different development languages. I
I am developing an iPhone application which logs data in a mySql database. Currently
I am currently developing a medium sized web application using PHP and need to
My company is currently developing a project management web application in PHP, and I
I am currently developing a php application using MVC techniques. I started it without
Currently I'm developing a web application. Which consist of frontend and backend interface. Therefore
I am currently developing an application which has a maps feature. My map is

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.