Thread: Url upload

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Url upload


    hi
    i want to upload a file to my server from a url
    i searched and i found this code:
    PHP Code:
    <?php
    define
    ('BUFSIZ'4095);
    $url '(type url here);
    $rfile = fopen($url, '
    r');
    $lfile = fopen(basename($url), '
    w');
    while(!feof($rfile))
    fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
    fclose($rfile);
    fclose($lfile);
    ?>
    my problem is that the url is from a file sharing site that have user and password for download
    how can i put user and pass to downalod in this code?
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,122
    Rep Power
    1990
    You'll need to do some (a lot) of work yourself to do this. It all depends on how the site handles it's membership login sessions.

    As a starting point that will get you to where you need to go, look at PHP's CURL library. That will do what you want, and probable more.

    Comments on this post

    • badger_fruit agrees
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    You should also know that this is probably in violation of the file sharing site's user agreement.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo