Sometimes, we want to create resumable downloads when using PHP to send the file.
In this article, we’ll look at how to create resumable downloads when using PHP to send the file.
How to create resumable downloads when using PHP to send the file?
To create resumable downloads when using PHP to send the file, we can use the mod_xsendfile
Apache module.
After we add the mod_xsendfile
module, we write
header("X-Sendfile: /path/to/file");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; file=\"filename\"");
to call header
to return the headers for the download file.
We set its MIME type with
header("Content-Type: application/octet-stream");
And we set the download file name with
header("Content-Disposition: attachment; file=\"filename\"");
Conclusion
To create resumable downloads when using PHP to send the file, we can use the mod_xsendfile
Apache module.