Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question getting a directory path from the user

    I am creating a system where files will be uploaded into the server, then I want to let the user to select a path of a directory in his PC where he want these files to be in his PC..
    Can some give hints how to use php to make my system do such functionality?
    (getting the path from the user by letting him browse the directory in his PC)???

  • #2
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This has nothing to do with PHP, but all you have to do is make a "file" text field, like so -
    Code:
    <input type="file" name="file_to_upload" size="20">
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but this will enforce the user to select a file, what I want is just the directory where the files will be downloaded there...

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    think it through and you'll realise it would be a huge securityhole if you could force downloading files into a specific directory on the client.

    you need to let the client decide which file he downloads and stores where.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This wont really be possible... The only slight possibility is if the user had a http server set up with the root in the C:\ drive (no-one in their right mind would ever do that).

    In terms of controlling files ect, there is no way to pre-define the value of a file upload, again, for security reasons, so what you are trying to do will be pretty much impossible.

  • #6
    New Coder
    Join Date
    Apr 2004
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    but my simple thinking that it just like downloading file, what the user must do is just to browse the folder he want the folder to be downloded in....?

  • #7
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you just want to direct a user to a place on their harddrive, then you should be able to use the full path, eg:

    Code:
    file://C:/Documents and Settings/user/My Documents

  • #8
    New Coder
    Join Date
    Apr 2004
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    So I will refhrase my question....
    How can I get the full path from the user from a browse window, not letting him to write it in a text field for example (This is because I am very kind and I want to make the user life easier)...

  • #9
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well you cant, not properly... and Im not sure about why you want to do this, or what for... If you want to get a path they you would probably need to utilize some sort of javascript in frames script? If you could tell us what you hope to achieve then we may be of more help.

  • #10
    New Coder
    Join Date
    Apr 2004
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I will explain what my system should do in short...
    first the scope of my system will be between students and a teacher..
    so the story begin when each student is going to submit his assignment in a zipped folder this folder will go directly into a specified directory in the server when the student submit his assignment...Now the role of the student is finished...
    The teacher will come and this scenario must happen>>>
    The teacher will press a button (Unzip Folders), when pressing this button a browse dialoge must pop up so the teacher must select a folder where the folders that were submitted by the student must be unzipped and the placed there....

    I finished implementing the student scenario, just remaning the teacher scenario..

    I can imagine that specifying the path by the teacher, is like specifying the root in dreamweaver...

  • #11
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you create a zipfile and then show a link to that file, then this should be enough. If the teacher clicks on that link, his browser will automatically open a dialogscreen asking him if he wants to open the file or save it + where he wants to save it.

    This dialogbox, where the client himself browses to the directory, is the only right way to handle this.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #12
    New Coder
    Join Date
    Apr 2004
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but our teacher dont want to this for each zipped file, he just want to click a button and all the files will be unzipped....

  • #13
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    if you know the path in advance .. ( you may be able to guestimate it given a known logical filesystem e.g. C:/students/$student_name/$data_name ) you can create an executable winzip file which will extract to wherever you configure , but I suspect your next Q will be how to do that from the winzip command line version & I have not a clue !
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #14
    New Coder
    Join Date
    Apr 2004
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What if I refhrase my question as the following...
    When the teacher come to see a page with all the files that were submitted by the student there( for the time being assume that they are normal files not zipped), so there will be a button at the button which has a lable "Copy these files to your PC" when the teacher clicks on this button the browse dialoge will appear so the teacher will chose a folder or a directory where all the files will be copied there....
    My question what is the peace of code so whnen the teacher clicks the button the browse dialoge will appear to let me select a folder, and then I can get the total path of the directory had been selected?????

  • #15
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    unless you zipped all the zips, each file would have to be downloaded separately... Why not use FTP through Internet Explorer to use a drag and drop windows interface?

    eg:

    ftp://www.yourhost.com/path/to/files

    (just make sure it has FTP access allocated)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •