Results 1 to 6 of 6

Thread: Read File Problem

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    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'); 

  2. #2
    Junior Member
    Join Date
    Apr 2006
    Posts
    18

    Re: Read File Problem

    Why not use include?

  3. #3
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    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::


  4. #4

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    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

  5. #5
    Junior Member
    Join Date
    Apr 2006
    Posts
    18

    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'

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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
  •  



Click Here to Expand Forum to Full Width