When I use the PHP
file system function fopen
to read a file from remote server in the following way:
<?php $filetoread = fopen ('https://www.abc.com/directory/file.php', 'r') ?>
I get the error
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized.....
After reading through several posts like this one https://stackoverflow.com/a/3335437 and PHP manual http://www.php.net/manual/en/function.fopen.php I come to know about it's resolution but because of inadequate information I can't get through the resolution properly.
For example, in the following resolution
http://user:password@www.domain.com/somefile.php
, what and how the username and / or password should be added? Are these the username & password of ftp
server? Is the resolution applicable for https://
too or fsockopen()
shall be better than fopen
in such case?