如何使用 PHP 从密码区域获取文件
我想制作一个脚本,该脚本采用文件的 URL 并将该文件导入到我的 Web 服务器中的特定文件夹 如果文件位于密码区域,如何请求文件,我有一个帐户“用户名/密码”,但我如何向该文件发出请求?
I want to make a script that takes a URL to a file and will import that file to a specific folder in my web server
how to request a file if it's in a passworded area, i have an account "username/password" but how can i make the request to that file ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于用于执行身份验证的机制。它可能是一个发出 cookie 的基于成形的系统(在这种情况下,您需要向 auth URI 发出请求并存储返回的 cookie),它可能是 HTTP 基本身份验证(在这种情况下使用 CURLOPT_USERPWD)。
It depends on the mechanism used to perform the authentication. It might be a formed based system that issues a cookie (in which case you need to make a request to the auth URI and store the returned cookie), it might be HTTP basic authentication (in which case use CURLOPT_USERPWD).
如果是 HTTP 授权,您可以这样访问它:
http://username: [电子邮件受保护]/folder/myfile.jpg
If it is HTTP Authorization you can access it like that:
http://username:[email protected]/folder/myfile.jpg