Results 1 to 6 of 6

Thread: remote download script

  1. #1
    Join Date
    Jul 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question remote download script

    I'm looking for a script that will allow me to upload files to a remote server from my local pc, as well as being able to upload downloadable files from other websites.
    ie. local pc upload path would look like c:/mydocuments/file.exe
    and the latter would look like http://www.website.com/downloads/file.exe

    Can this be done?
    If so, can someone give me a hand since I have no idea how to code.
    Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Do you know if this will allow me to upload files to my server from web links?
    I currently have ezUpload Pro 2.2 (http://www.scriptscenter.com/ezupload/) but it doesn't allow me to upload files from other websites, just from my local machine.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That one's easy.
    PHP Code:
    <?php
    $url 
    "http://www.crystalinity.net/images/ginger.png";
    $dir "/home/twey/public_html/downloads/";
    $rfile fopen($url"r");
    $lfile fopen($dir basename($url), "w");
    while(!
    feof($url)) fwrite($lfilefread($rfile1), 1);
    fclose($rfile);
    fclose($lfile);
    ?>
    Requires URL file-access to be enabled on your server.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Dec 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Correction

    while(!feof($rfile)) instead of while(!feof($url))

    Apart of this, the code works flawlessly.

    Best regards,
    Marius

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Indeed so. A larger buffer size would probably result in increased performance too:
    Code:
    <?php
      define('BUFSIZ', 4095);
      $url = 'http://www.twey.co.uk/images/ginger.png';
      $dir = '/home/twey/public_html/downloads/';
      $rfile = fopen($url, 'r');
      $lfile = fopen($dir . basename($url), 'w');
      while(!feof($rfile))
        fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
      fclose($rfile);
      fclose($lfile);
    ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •