开发者

Downloading file programmatically with HTTP authentication [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

H开发者_如何学JAVAow can I provide these credentials in PHP and retrieve the file?

Downloading file programmatically with HTTP authentication [closed]


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:password@url.to/file");

Hope this helps.


You can use cURL to submit form data.

Take a look here cURL tutorial and here php cURL

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜