opening a file on a remote server

Discussion in 'PHP' started by daboss, Sep 28, 2006.

  1. #1
    i need to open a text file on a remote server (linux) using php. should i use fsockopen or fopen?

    i understand that fopen can only work if 'allow_url_fopen' is set in the php.ini file - so is fsockopen always better than fopen?

    any advice at all is very much appreciated.
     
    daboss, Sep 28, 2006 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #2
    Both of this functions will fail if allow_url_fopen is switched off. This setting cannot be redefined with .htaccess or ini_set, so you need to have it enabled in php.ini.

    I think fopen is more simple than fsockopen. Also you can use the simplier function file_get_contents for file reading (PHP>=4), and file_put_contents for writing (PHP>5).
     
    wmtips, Sep 29, 2006 IP
  3. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #3
    noppid, Sep 29, 2006 IP
  4. ivenms

    ivenms Peon

    Messages:
    334
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Why you want to open remote files?

    Is there any place hold text files with contents?
     
    ivenms, Sep 29, 2006 IP
  5. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks for the replies...

    i'm the developer of a script that i distribute freely. in the control panel of the script, i'm adding code to communicate with my web server to determine the latest version of the script. i have the information stored in a text file in my web server - that's why i need to open remote files... ;)

    any ideas?
     
    daboss, Sep 29, 2006 IP