I want to download a file (e.g. http://rapidpich.ir/d/555864) programmatically using php. However, when I attempt to follow the link in my web browser, I'm asked for a username and password.
How can I provide these credentials in PHP and retrieve the file?

Usually to grab a file you'd write something like:
$file_contents = file_get_contents("http://url.to/file");
You may do something other than store into a variable, or you may use a different function.
If the file is protected by HTTP authentication, you can usually specify the credentials in the URI:
$file_contents = file_get_contents("http://username:[email protected]/file");
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With