-
Read File Problem
I'm trying to read a txt file from another site but no matter what I try I get the below error.
Code:
Warning: fopen(http://www.mysite.com/files/myfile.txt): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
This is the code I've tried....
PHP Code:
$handle = fopen("http://www.mysite.com/files/myfile.txt", "r");
and
$handle = file('http://www.mysite.com/files/myfile.txt');
-
Re: Read File Problem
-
Re: Read File Problem
Er, I don't think those commands support opening files outside of the server. Is that what you are trying to do? If not, then don't include the "http://www.mysite.com/" in there, simply just include "/files....".
-
Re: Read File Problem
uainfantry, can I use include for a file on another website?
eg. my site = www.mysite1.com
file i want resides on www.mysite2.com
-
Re: Read File Problem
Yea, it will load the file into a table or whatever you want to load into.
PHP Code:
include('http://www.mysite2.com/index.html')
-
Re: Read File Problem
Include is not the same as fopen(). To use the file functions across HTTP you need to set allow_url_fopen = 1 in php.ini. If you are getting a bad request error then try accessing it through the browser, it may be a misconfiguration on the remote server.