Results 1 to 6 of 6

Thread: How to use Remote Files in PHP?

  1. #1
    Join Date
    Aug 2006
    Posts
    148

    How to use Remote Files in PHP?

    Hi friends,
    I have recently started working with the PHP programming language, so I am not having much knowledge about it. I have done the basic things that are required for the basic PHP coding. Now I want to use the remote files, which I am not having any idea about doing it.!! Please tell me how to use Remote Files in PHP? Hope that someone would reply me soon.!!
    The Gaming Machine:
    Processor: Core 2 Duo E6400
    Motherboard: Asus P5W DH Deluxe
    RAM: 2GB XMS2 Corsair PC2-6400
    Video: ATI Radeon X1900XT 512MB w/ Arctic Accellero
    Drive: 74GB "WD Raptor" 10000RPM
    Sound: Creative SoundBlaster X-Fi
    Watercooling: *Soon* Zalman Reserator

  2. #2
    Join Date
    Jul 2006
    Posts
    286

    Re: How to use Remote Files in PHP?

    As long as the media handlers URL ( "URL fopen wrappers") is enabled in php.ini with the allow_url_fopen option, you can use URLs like HTTP and FTP with the majority of functions that use a name file as a parameter. This includes include (), include_once (), require () and require_once (). Since PHP 5.2.0, allow_url_include must be enabled for these. The language of instruction include () statement includes and evaluates the specified file. The files are included following the file path provided, if none is provided, the include_path will be verified.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  3. #3
    Join Date
    Jul 2006
    Posts
    442

    Re: How to use Remote Files in PHP?

    I would like to tell you that in PHP 4.0.3 and newer, to use the URL handlers, you must configure PHP with - enable-url-fopen-wrapper. Also you will have to keep in mind that versions of PHP for Windows earlier than 4.3 did not support remote file accessing for the following functions: include (), include_once (), require (), require_once (), and functions to create images extension functions and GD images. he language of instruction include () will issue a warning if it does not find a file while the language of instruction require () will issue a fatal error in the same case.
    "When they give you ruled paper, write the other way..." J.R.J.

  4. #4
    Join Date
    Aug 2006
    Posts
    227

    Re: How to use Remote Files in PHP?

    You can follow the following example to open a file on a remote web server, analyzing the results to extract the information you need, and then use it in an application database, or simply edit the information in the style of your site. The following example provided by me is for getting the title of a remote page :
    PHP Code:
    <?php
    $file 
    fopen ("http://www.demo.com/""r");
    if (!
    $file) {
        echo 
    "<p>Unable to open remote file.\n";
        exit;
    }
    while (!
    feof ($file)) {
        
    $line fgets ($file1024);
        if (
    preg_match ("@\<title\>(.*)\</title\>@i"$line$out)) {
            
    $title $out[1];
            break;
        }
    }
    fclose($file);
    ?>
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  5. #5
    Join Date
    Jul 2006
    Posts
    289

    Re: How to use Remote Files in PHP?

    If a path is defined whether full path or relative, the include_path will be ignored. When a file is included, the code it contains inherits the variable scope of the line where the include occurs. All variables available at that line in the calling file will be available in the called file, from this point. However, all functions and classes defined in the included file have global scope. Whereas the include_once () statement includes and evaluates the specified file during script execution. The behavior is similar to include (), but the difference is that if the code has already been included, it will not be a second time.
    Signatures reduce available bandwidth

  6. #6
    Join Date
    Nov 2008
    Posts
    996

    Re: How to use Remote Files in PHP?

    To connect with another anonymous user, you must specify a user-name (and possibly password) within the URL as ftp://user:password @ ftp.demo.com / path / to / file. You can use the same type of syntax to access files via HTTP when they require authentication. The following is an example for storing data on a remote server :
    PHP Code:
    <?php
    $file 
    fopen ("ftp://ftp.demo.com/incoming/outputfile""w");
    if (!
    $file) {
        echo 
    "<p>Unable to open remote file for writing.\n";
        exit;
    }
    /* Write the data here. */
    fwrite ($file$_SERVER['HTTP_USER_AGENT'] . "\n");
    fclose ($file);
    ?>

Similar Threads

  1. Replies: 5
    Last Post: 19-04-2011, 10:37 PM
  2. Replies: 4
    Last Post: 19-04-2011, 10:41 AM
  3. Replies: 5
    Last Post: 24-12-2010, 02:07 PM
  4. Script to Search and Delete Files from Remote Machines
    By binuthomas in forum Windows Server Help
    Replies: 24
    Last Post: 20-08-2008, 11:53 PM
  5. Replies: 2
    Last Post: 11-12-2007, 03:26 PM

Tags for this Thread

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
  •  
Page generated in 1,714,065,154.45917 seconds with 16 queries