Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Download Files From Sever Using PHP Script

In this tutorial, we are going to discuss how to download simple image file from the server location to local machine. Using this technique you can download all kind of files, which includes image, document, zip, PDF etc. This method is followed by most of the PHP websites to perform download operations.




Lets see the below simple php script, which help us to download files from server.
download-file.php
php
//Image file at sever loaction to download
$file
= 'skp.png';

if (file_exists($file)) {
header
('Content-Description: File Transfer');
header
('Content-Type: application/octet-stream');
header
('Content-Disposition: attachment; filename="'.basename($file).'"');
header
('Expires: 0');
header
('Cache-Control: must-revalidate');
header
('Pragma: public');
header
('Content-Length: ' . filesize($file));
readfile
($file);
exit;
}

Video Link : 


Download Link :
https://github.com/skptricks/php-Tutorials/tree/master/How%20to%20Download%20Files%20From%20Sever%20to%20Using%20PHP%20Script

This is all about PHP download file script. Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section.




This post first appeared on PHP Update Data In MySQL Database, please read the originial post: here

Share the post

How to Download Files From Sever Using PHP Script

×

Subscribe to Php Update Data In Mysql Database

Get updates delivered right to your inbox!

Thank you for your subscription

×