Download file to website using php -
this question has answer here:
- download file server url 10 answers
i have file url !
$url = "http://www.example.com/aa.txt";
and want download file , save path on website
this website ( online )
$path = "server/username/";
i want $url
file saved $path
,,
i try
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; } ?>
when test code , make file download computer not website
you can use file_put_contents();
see manual here:http://php.net/manual/en/function.file-put-contents.php
a different implementation here:http://www.finalwebsites.com/forums/topic/php-file-download
Comments
Post a Comment