I hope you all are well. Today I am going to write post on How can make to user download the file from the another website without showing them that the file is actually coming from another server?
This can help many beginners PHP User to to Hide File URL Location in PHP. Here is the example how can u fetch file from other website and give download to the user like its downloading from our website.
Here is the Nice code:
<?php $file="http://example.com/example.jpg"; // replace this URL with your URL header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; ?>
Very Easy to understand.
Ask if you Have any query.
Thank you.. 🙂