download a file by php code-PHP download files code

Basic example for download a  file by php

<?php
$file="http://testexample.com/your_test_file.jpg"; // path to your file
 header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Length: ' . filesize($file));
readfile($file); exit;
?>

download a file by php code

OR

<?php
header("Content-Transfer-Encoding: Binary");
        header("Content-length: ".filesize($dest_file_path));
        header('Content-Type: text/xml');
        header('Content-Disposition: attachment; filename="'.$dest_file_name.'"');
        readfile($dest_file_path);
?>