Hi,
I'm trying to download a file from a http page (note not ftp) that requires user authentication. The file can be downloaded manually by clicking on the link. I would like to do this automatically using a PHP script.
Here's the code I am using:
$srcFilePath = "
http://username:password@www.mydomain.com//filename.txt ";
$desFilePath = "filename.txt";
if (!copy($srcFilePath, $desFilePath)) {
echo "failed to copy $file...
";
I get the following error with the above code:
Warning: copy(
http://username:password@www.mydomain.com//filename.txt) [function.copy]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /
Comments
:
: I'm trying to download a file from a http page (note not ftp) that
: requires user authentication. The file can be downloaded manually by
: clicking on the link. I would like to do this automatically using a
: PHP script.
:
: Here's the code I am using:
:
: $srcFilePath =
: "http://username:password@www.mydomain.com//filename.txt ";
:
: $desFilePath = "filename.txt";
:
: if (!copy($srcFilePath, $desFilePath)) {
: echo "failed to copy $file...
";
:
: I get the following error with the above code:
:
: Warning:
: copy(http://username:password@www.mydomain.com//filename.txt)
: [function.copy]: failed to open stream: HTTP request failed!
: HTTP/1.1 400 Bad Request in /
: :
: : I'm trying to download a file from a http page (note not ftp) that
: : requires user authentication. The file can be downloaded manually by
: : clicking on the link. I would like to do this automatically using a
: : PHP script.
: :
: : Here's the code I am using:
: :
: : $srcFilePath =
: : "http://username:password@www.mydomain.com//filename.txt ";
: :
: : $desFilePath = "filename.txt";
: :
: : if (!copy($srcFilePath, $desFilePath)) {
: : echo "failed to copy $file...
";
: :
: : I get the following error with the above code:
: :
: : Warning:
: : copy(http://username:password@www.mydomain.com//filename.txt)
: : [function.copy]: failed to open stream: HTTP request failed!
: : HTTP/1.1 400 Bad Request in /