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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:41:44+00:00 2026-05-20T21:41:44+00:00

Trying to get the entire file downloaded — but I assume the script is

  • 0

Trying to get the entire file downloaded — but I assume the script is exiting with the first chunksize pass in the stream.

What needs to be coded in to get full file size download?

$image_link=$_GET['image_link'];
$fullPathDL=$path0.$image_link;
$fsize = filesize($fullPathDL);
$path_parts = pathinfo($fullPathDL);
if ($fd = fopen($fullPathDL, "rb")) {
    $fsize = filesize($fullPathDL);
    header("Content-type: application/jpg"); // add here more headers for diff. extensions
    header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
    header("Content-length: $fsize");
    //    header("Cache-control: private"); //use this to open files directly
        while(!feof($fd)) {

$buffer = fread($fd, 8192); echo $buffer; } fclose ($fd); exit;

}

  • 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-20T21:41:45+00:00Added an answer on May 20, 2026 at 9:41 pm

    The reason why your example doesn’t work is the entirely present in the buffer.
    It’s been awhile since I’ve looked at the standard, but at least I can give you a step in the right direction. Basically, when reading from chunked-transfer, the first couple bytes I believe represent the number of bytes in the chunk. Something like this (taken from wikipedia).

    25
    This is the data in the first chunk
    
    1C
    and this is the second one
    
    3
    con
    8
    sequence
    0
    

    You basically need to check the number of bytes to read, read the bytes, and repeat until the number of bytes to read is 0.

    The easiest way to accomplish this is to either specify in your request headers HTTP 1.0 (which does not support chunked transfer), or use a library which handles this for you, i.e., CURL.

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

Sidebar

Related Questions

I am trying to get the entire raw header into a file but everytime
I am trying to get a layout that always takes up the entire screen,
Trying to get an ASP application deployed; it worked for a while but then
I'm trying to write a .gitignore file. I'd like to get a preview of
I'm trying to achieve a simple substitution on vim but can't get it right.
I'm trying to get the download link of wordpress' plugins via bash script directly
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
I am trying get Struts 2 and Tiles to work and I am using

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.