Jump to content

Download Launch Headers


akshay

Recommended Posts

Hi.

 

$fullPath="/any/path/to/file/file.ext";

$fd = fopen ($fullPath, "r");

if ($fd) {
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
        case "pdf":
        header("Content-type: application/pdf"); // 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;\n");
        break;
        default;
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
        header("Content-Length: $fsize;\n");
    }
    header("Content-length: $fsize");
    header("Cache-control: private; max-age=3600"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd);
exit;

 

I've specified max-age with headers. Yet, download is "non-resumable"

How can I make it resumable? So that valid for , say 3 days or so? or ever-valid?

 

Please help!

 

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/208426-download-launch-headers/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.