Downloading files from server

Hey!

I’m currently working on a website for a client and I need a script that enable users to log in and download files from a server, the files does also need to be displayed on the website (once logged in) with filename and a download link.

I want to display each file from one folder in a

  • with a download link.

    Any help will be much appreciated!

  • What do you need help with?

    the login/logout scripts?
    the database for storing the users?
    the database for storing the files?
    the script for presenting the links?
    the download script?

    Which part(s) do you need?
    Note: If you say ‘all’, please contact me via my signature link and we can discuss the fee :wink:

    Echris,

    This is a free site, not a paying one. No fees needed to help you. So, in PHP, you may parse thru a folder and pull the filenames of each file. This would simply need to be placed into your

  • 's as an anchor with the HREF pointing to the path and filename of each file.

    When the user wants to download one, they click on it and it should download. There are some minor issues here as some browsers and some user’s system automatically open files with certain extensions. On one of my systems, if I click on a link pointing to a picture it displays in the browser and then I have to save it from there. On my main system, it just saves the picture. So, you may wish to place a note to tell the user to RIGHT-CLICK on the link and SAVE-TARGET-AS to make sure the file is downloaded and not opened. Hope that makes sense.

    Now, I assume, you already have the files in a folder. So, first, you have to create a list of all of the file names in the folder. This can be done in PHP with ease. Here is a sample taken right off the PHP.NET site:
    From http://php.net/manual/en/function.readdir.php
    [php]
    if ($handle = opendir(’/path/to/files’)) {
    while (false !== ($entry = readdir($handle))) {
    if ($entry != “.” && $entry != “…”) {
    echo “$entry\n”;
    }
    }
    closedir($handle);
    }
    [/php]
    This code just reads the file names in the folder. You have to change the path-to-files in the first line to point to your folder. Also, where it echo’s the filenames, you can alter that to be something more like:
    [php]
    echo "<a href=“http://yoursite.com/path-to-files/” . $entry . “>

  • ” . $entry . “
  • ”;
    [/php]
    Then, your page would have the anchor wrapped around the
  • and when they press on it, it gives up the file. This was untested, just off the top of my head, but, should work. Drum it up and let us know if it does not work. Good luck…
  • 1 Like

    ErnieAlex:

    On the homepage of this site in the righthand box at top of screen states:

    “Here you can also find freelance PHP programmers or PHP webmasters to work with you on your project.”

    As a freelance programmer, I come to this site and offer help free of charge quite regularly. Whilst I have no problems with this as I do it in my own time and like to give a little back to the php community, I am however, entitled to enquire about fee’s for project’s I deem large enough to require one.
    Let’s be honest, some folk want the entire system built for them and that’s cool with me, as long as they’re willing to pay for my time.

    Maybe you could clarify the statement on the front page for me??

    Cheers,
    Red.

    Redscouse, Kudo’s to you. I am very glad you are making money as a freelance PHP programmer! Serious, that is great!

    But, this member was asking such a simple question, he/she did not have to pay for an answer to it. The answer could be found in our archives and I wanted to make sure that they understood they do not have to pay for this answer. Your response to them was six (6) questions to their one question without any help at all. I just wanted them to understand their options.

    Sorry if my response offended you. I did not say anything bad about you and did not imply that either. Please continue your great answers to so many questions as in the past. You have been very helpful to many.

    Cheers back at ya, keep up the great help!

    ErnieAlex,
    If I came across to the original poster that I charge for everything, I apologise to him/her, that was not what I meant. When I read the question, my reply wasn’t meant to sound harsh or unkind. :-[ I was in fact trying to point out that it wasn’t a simple ‘one-script-does-everything-the-poster-asked’ and it would be more like several scripts (login,downloads,uploads,display files, logout << there’s six right there) - and if they needed help, with which part? (and the line about fee’s was meant more like, “i’ll help you if you’re stuck, but I won’t build the entire system for you - for free”)

    You have no need to apologise to me, you’re question never offended me, I merely wanted to be sure I wasn’t breaking forum rules when I enquired about the statement on the front page. (If I got offended every time someone challenged something I’ve said, I’d be running round with steam coming from my ears all day long as my job requires people to challenge the things I say to help with their understanding of what I just said. :o :wink:

    Sponsor our Newsletter | Privacy Policy | Terms of Service