PHP enables you to download the file easily using a built-in readfile() function. The readfile() function reads a file and writes it to the output buffer.
int readfile ( string $filename [, bool $use_include_path = false [, resource $context ]] )
File Name: download_file.php
<?php
$file_url = "http://www.easytolearning.com/file.txt";
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: utf-8");
header("Content-disposition: attachment; filename="" . basename($file_url) . """);
readfile($file_url);
?>
File Name: download_file1.php
<?php
$file_url = "http://www.myremoteserver.com/file.exe";
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename="" . basename($file_url) . """);
readfile($file_url);
?>
© 2024 Easy To Learning. All Rights Reserved | Design by Easy To Learning