SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    ::==:: Bonzo_CS's Avatar
    Join Date
    Dec 2003
    Location
    (Cardiff Wales)
    Posts
    747
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Read contents of a remote file

    Hi All,

    I've been chasing my tail with the best way forward regarding the following problem. Please feel free to comment.

    Basically I wish to read the contents of a remote file. The file type will be php, or HTML, but sits above the remote servers webserver. Therefore I cannot use a HTTP request as I need to pass the absolute path.

    An example being the remote file sits on usr/files/somefile.php on server 192.1.1.1.

    How would you suggest I connect to 192.1.1.1 then read the contents of the file usr/files/somefile.php? Please be aware I do have access to cURL, but am not 100% up to speed with the FTP side of the package.

    Thanks all.

  2. #2
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear guy:

    The file that you want to read must was not disabled by admin host [ex: .htaccess file ].
    I have two solution for u:
    1 -> use Ajax with get method to get content its.
    2. Use php function to do that.
    With solution second you can read php manual or search in google for this problem .

    file_get_content('path to file');
    file_open("path to file ", "rb"); [ notice: two method for this function : http and ftp ]

  3. #3
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the file is not directly available via HTTP, AJAX or any other browser request (besides FTP), would not do any good. Using PHP's builtin FTP system is a little easier than doing it through the CUrl extension.

    There are only two other possibilities. One is to use SCP or sftp with the SSH2 extension. The other is to have a password protected, HTTP accessible PHP script on the remote machine that can use file functions to retrieve the file for you.
    Last edited by Hammer65; Aug 9, 2007 at 09:00.

  4. #4
    ::==:: Bonzo_CS's Avatar
    Join Date
    Dec 2003
    Location
    (Cardiff Wales)
    Posts
    747
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Hammer65,

    I'm looking at a few possible solutions on what you suggested. Somebody suggested using webDAV as well which I may take a look at.

    Cheers


Bookmarks

Posting Permissions

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