The source code to download the text file from the specified URL is given below. The given program is compiled and executed successfully.
<?php
//PHP program to download the text file.
$download_url = 'http://www.includehelp.com/sample.txt';
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: utf-8");
header("Content-disposition: attachment; filename="" . basename($download_url) . """);
readfile($download_url);
?>
Explanation:
Here, we created a variable $download_url that contains the file URL that will be downloaded. After that, we prepared the header and call readfile() to download the file.
Program/Source Code:
The source code to download the text file from the specified URL is given below. The given program is compiled and executed successfully.
Explanation:
Here, we created a variable $download_url that contains the file URL that will be downloaded. After that, we prepared the header and call readfile() to download the file.
need an explanation for this answer? contact us directly to get an explanation for this answer