|
-
Apr 11th, 2006, 06:56 PM
#1
Thread Starter
PowerPoster
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');
-
Apr 13th, 2006, 07:47 PM
#2
Junior Member
-
Apr 14th, 2006, 12:17 AM
#3
Frenzied Member
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....".
Age - 15 ::: Level - Advanced
If you find my post useful please ::Rate It::

-
Apr 14th, 2006, 01:12 AM
#4
Thread Starter
PowerPoster
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
-
Apr 14th, 2006, 01:18 AM
#5
Junior Member
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')
-
Apr 14th, 2006, 02:12 AM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|