PDA

View Full Version : Can't access remote files


SteveC
2003-10-01, 14:48 PM
Hopefully someone here can help me.

Whenever I try to access a remote file via PHP (via include, require, fopen, etc) I get a "failed to open stream" error. Any ideas on how I can fix this?

In the PHP configuration settings the "allow_url_fopen" parameter is on, so it's not that.

Any help would be greatly appreciated. I can't access any XML files from remote sources. I can't access files from any of my other web sites. I can't access anything remote!

Thanks!

SteveC
2003-10-02, 05:23 AM
Nevermind. I semi-figured it out. It won't access remote files on some domains.

For example, I have a site hosted with another virtual host. I can't access any files on that server with include, fopen, etc. when using the standard "www.mydomain.com".

However, I looked in the admin panel and found another domain (most likely the one with the actual IP address is assigned to), "mydomain.com.othersite.com". Using that domain I am able to access remote files.

So, I'm guessing that I can't access remote files that use name-based DNS. Does this sound right? If this is the case, is there a way around it?

Thanks.

dhigbee
2003-10-02, 21:15 PM
Steve,

Did you try fsockopen? How about cURL? Both of these should work in reading in remote files. You can read up more about it at - fsockopen (http://us3.php.net/manual/en/function.fsockopen.php) and cURL (http://us3.php.net/manual/en/ref.curl.php)

On the fsockopen page under user contributions, there is a link to a php class called snoopy. It is suppossed to emulate a web browser with PHP using socket functions. Looks interesting.

I have one thought about getting xml files. Is the sending server setup to send them?

Don