Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Junior Member
    Join Date
    May 2003
    Posts
    18
    Member #
    1365
    Hi,

    I've been breaking my head trying to find a solution for this (it seems most people who come here are already deperate )

    The <input type=file> tag of html lets the user select one file only. Is there a way to allow the user to select multiple files? as in windows regular "open file" browse window?

    While on the subject, is there a way to allow a user to select a directory and not a file name? i.e. as a variable?

    Thanks in advance,
    Roy.

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    The "file" input is limited because of the nature of encoded file transfer over the web. You can't specify multiple files with one transfer name - there would be no way to parse the data once it reached the server, and you'd either wind up with one big file or one corrupt file once it got there.

    The only way you can do it the way you want is to create a custom control using a <select> control (with multiple rows), a "text" input, an "add" button, and multiple hidden file inputs. Have the user select a file and "add" it to the select box (using DOM). At the same time, hide the file selection and make one of the hidden ones appear. When the form is submitted, it will "appear" to have submitted multiple files to the server.

    I don't know of any way to transfer a folder. Remember that a folder is a data structure specific to your operating system. The WWW only supports global standards.

  4. #3
    Junior Member
    Join Date
    May 2003
    Posts
    18
    Member #
    1365
    Thanks very much for the reply.

    I find what you say very interesting.

    Let me explain what I'm trying to accomplish. Maybe that will turn on a few light bulbs.
    I am working with a java applet that handles files. I need to give it either a string of file names or a directory name (both configurable by the user).

    Currently, I allow the user to enter text items, but I wish to allow browsing for files/directory selection. These browsing windows are the problem. How do I go about creating them?

    Thanks again,
    Roy.

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    IIRC Swing has a CommonDialog-like component that you can use. However crossplatformness will still be a problem. The only real other solutions are either similar to what Transio said, or to ask the end-user to zip up the files.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Filburt, I think he's using a pre-built applet, which means he can't customize the Swing interface (if there is one at all).

    Jorik, As far as your second question, you can't customize the file-browsing capabilities of an HTML form at all. It is the way it is because of security restrictions. Giving a browser access to your directory structure would allow hackers to abuse it.

    If you really NEED folder access, I suggest you go with a thick-client component that allows it (such as a compiled Active X component or an applet that will allow folder access). Since you're using an applet already, you probably shouldn't mind doing this. It will require modifying the applet you're using already, though, or replacing it completely if you don't have the source.

    Note that Active X components won't work on non-windows platforms.

  7. #6
    Junior Member
    Join Date
    May 2003
    Posts
    18
    Member #
    1365
    Your'e right transio, I am using a pre-built applet - but it was built by one of the developers in my company

    I guess that the best way to go is to have the applet "probe" the user's machine for the files and let me display them for the user to choose from. The developer's applet is already doing this - we just need now the import to javascript. I wanted to avoid that as to provide the user with an intuitive "built-in" interface.

    Guess I'll have to do it myself.
    Thanks a lot guys. Good thing I found this place! I'll be sure to come here in the future
    Roy.

  8. #7
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    If you use an Active X control, you can avoid the need to do all that by making Thick-Client windows controls available through your interface (like a file list dialog). It should also be a lot easier to program. Something like that should be relatively easy with VB. If you want, I can throw something together for you.

  9. #8
    Junior Member
    Join Date
    May 2003
    Posts
    18
    Member #
    1365
    Wow! This forum is great!

    Thanks transio. But, correct if I'm wrong (I probably am), active X works only on windows clients - right?

    I need to make cross-platform...

  10. #9
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Correct. Windows only. But consider this... I made the following file selection control in 5 minutes.

    :-P

  11. #10
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Here's the OCX for the control (zipped)


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:58 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com