Results 1 to 2 of 2

Thread: URL Download script

  1. #1
    Join Date
    Sep 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up URL Download script

    Please help me my friend,
    URL Download script- i need a script which download files using URL from other site to our server directly..

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Why? You can save a link to your computer by choosing right click, save as. If you decide to route the file through your server, it will be slower (downloading twice) and they will still have to right click, save as. It will waste your bandwidth and be a hassle for the user.

    If you are attempting to make a proxy site, that might be useful, but still would waste your bandwidth. Also be sure you have permission from the sites you are getting files from, unless you are letting the user choose while files he wants.

    Anyway, here's the basic way to do it:
    http://www.php.net/manual/en/function.fread.php
    Use a function like that (there are a few ways) to get the contents of the file.
    Use fwrite() to save it to your server.
    Then just let the user have a link to that file.

    Alternatively you could actually grab the contents of the file (fread, etc.) and directly output it including headers so that it isn't a webpage served by php, but instead the actual file. But with big files this would be a huge delay (the entire transfer time to your server).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •