Answer the question
In order to leave comments, you need to log in
How to download a file from a link to a computer?
I am using the file_put_contents() and fopen() functions.
file_put_contents("test.mp4", fopen('https://site.com/file.mp4', 'r'));
if (file_exists($request['url'])) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$request['url'].'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($request['url']));
readfile($request['url']);
exit;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question