PHP Guru - need ur help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qw12er
    Confirmed User
    • Apr 2004
    • 799

    #1

    PHP Guru - need ur help

    I want to "Download' a file from a remote server with a PHP script.

    I used this function below, but I need to enable the remote file opening option in php.ini to make it work. Let's say that I can't turn on this option for some reason. What else can I do to avoid this problem ? Is FTP functions my answer ?

    Thanks

    function download($file_source , $file_target) {
    $rh = fopen ($file_source, 'rb');
    $wh = fopen($file_target, 'wb' );
    if ($rh===false || $wh=== false) {
    return true;
    }
    while (!feof($rh )) {
    if (fwrite($wh, fread( $rh, 1024)) === FALSE) {
    // 'Download error: Cannot write to file ('.$file_target.')';
    return true ;
    }
    }
    fclose($rh);
    fclose ($wh);
    // No error
    return false;
    }
    I have nothing to advertise ... yet.
  • qw12er
    Confirmed User
    • Apr 2004
    • 799

    #2
    note : I'd like not to use the FTP functions since I don't want to maintain an anonymous FTP account only for this file ...

    Is there anyway to temporarily set the remote file opening option on ?
    I have nothing to advertise ... yet.

    Comment

    • AcidMax
      Confirmed User
      • May 2002
      • 1827

      #3
      You could try ini_set to try and set the option you need on in the script, but I think you are going to have to use the fsockopen functions to do the remote ftp, or if your php version has the ftp functions compiled into it, just use php's ftp ability.
      Latest MMA news. http://www.mmawrapup.com

      Comment

      Working...