How to download file through URL using PHP
Posted: Wed Jun 22, 2005 4:02 am
How to use PHP to download a file/picture by given a URL. And save the downloaded file to disk.
Thanks.
Thanks.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
... well, I do believe I'm a bit older now than I was when I first posted this postif you were faster then light, techniqally (dont know how to spell that) you would be moving through time...
Code: Select all
header("Content-type: text/plain"); //here you will have to mention the file type
header("Content-Length: 1024"); // this is the filesize
header("Content-Disposition: attachment; filename=test.txt"); // filename is the name you want to store the file as.It can also be any other name
include 'test.txt'; // this is the file that you want to downloadcan fread do this:
I just want to down load a file using PHP.asmie wrote:To download a file you will have to specify the header information in your script.
It will be like this :
Yenjoyy !Code: Select all
header("Content-type: text/plain"); //here you will have to mention the file type header("Content-Length: 1024"); // this is the filesize header("Content-Disposition: attachment; filename=test.txt"); // filename is the name you want to store the file as.It can also be any other name include 'test.txt'; // this is the file that you want to download
A s m i e