Answer the question
In order to leave comments, you need to log in
How to write a PHP script to download a file after a redirect?
There is a site. It gives files like site.ru/do.php?id=123
I want to download a file using php.
Tried:
@fopen($path, "r");
file_get_content($path);
and also via cURL.
When the page opens in the browser, the download of the file starts. When you pick up a file through a script, the html page itself is recorded when opened, the file is downloaded.
As I understand it, the header is being checked, but I passed it as a parameter via cURL, it didn’t work (well, my hands are crooked).
Can someone tell me how to do it right?
Answer the question
In order to leave comments, you need to log in
Show what went wrong with curl.
Maybe just Follow_location was not set.
If nothing happens, it doesn't happen.
This is the easiest way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question