Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    87
    Thanks
    0
    Thanked 1 Time in 1 Post

    fopen(), fwrite() on a remote file

    I have developed a little script that runs in the background, from the command line and starts off as a cron job every morning. I use fopen() function to check for the updates of some remote URLs. If the remote file is updated, the script uses fopen and fwrite to open / writes to the local file and change it accordingly. The file is located in my phpdev\www directory and, with help of eregi_replace I change it so it can be used to feed my database.

    However, I have to upload this text file to the (remote) server every time and run different script thru the browser in order to update my database.

    It would be hack of a lot better if I could fwrite to the text file on my remote server (skipping the manual upload), but, whenever I try to do that, die() function throws the error: "can't open the file"... I suspected permissions problems and changed the file and folder permissions (even to 777)... still it doesn't work. As a test, I have tried to fopen the document on my web site, but that also failed. I have checked php.ini on my machine and "allow_url_fopen" is set to "on". However, when I try fopen some document on different web site, it works...

    Any suggestions?

    Thanks,

    Neno
    Neno

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Through which protocol are you trying to write the remote file? It can't work over http, but over ftp it would be possible. If that doesn't work still, you could put a php script on the remote server which is responsible for the writing of files. This file you could then request through fopen("http...").

    Apart from that, posting some of your code would be very helpful.
    De gustibus non est disputandum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •