Hi, I'm trying to download a file from a http page 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://usernameassword@www.mydomain.com//filename.txt "; $desFilePath = "filename.txt"; if (!copy($srcFilePath, $desFilePath)) { echo "failed to copy $file...\n"; I get the following error with the above code: Warning: copy(http://usernameassword@www.mydomain.com//filename.txt) [function.copy]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /…/ADETEST/ADETEST3.PHP on line 27 Thanks in advance Ade
Are you trying to download the file via http or ftp (you seem to be doing ftp, using http protocol)? Peace,
Thanks for your responses... I'm trying to download the file via http. How do I download via http? Replacing double slash with single slash makes no difference.
Thanks for your response. I have tried the code in the suggested link. A file is created but it has a size of 0KB, and is empty. Any suggestions?
" failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request " " A file is created but it has a size of 0KB " Are you sure the file your grabbing both exists and hasn't got anything blocking you from accessing it. Whats the file you're trying to grab.