[Javascript] file upload

Mike Dougherty mdougherty at pbp.com
Mon Nov 29 10:08:33 CST 2004


javascript isn't normally allowed to access the file system, so you would need some way to 
authorize your script (which rules out every use but an intranet where you can force users to 
accept conditions)  The method for authorizing this access is likely to be different for every 
browser (so you'll have X times the work, or you have to build to a specific browser - which again 
is usually only acceptable in an intranet environment)

My suggestion would be to use the <input type='file'> the way it is minimally supported by each 
browser.  IE allows a single file pick per input, but I read once there are others that do allow 
multiple files per input.

If you wanted to clean up the interface, i would suggest the following (unproven) strategy:

Provide a list as you described
Provide a single file input to "Add" to the list
After the user makes a selection-
  add the filename to the list,
  using CSS, hide the [now filled] file input
  insert a new file input to "Add" another file

When the form is submitted, the normal behavior of the file inputs will be honored - the key is to 
not even try to re-invent the file input.  The native file upload funtionality of the browsers 
I've used is weak, and hardly "extensible" - I gave up trying to ask too much of file uploads.

I'd offer that any way you can make work is as close to the "correct" way as you can get. :)

Good luck

On Sun, 28 Nov 2004 19:46:28 +0100
  "Iztok Polanic" <iztok.polanic at amis.net> wrote:
>Hi!
>
>Interesting problem. Atleast for me :)
>I'm trying to make a file upload in javascript. It will go something like
>this.
>The user will select all the files he or she wants' to upload and the
>filenames will be displayed in a box (innerHTML). When the user clicks send,
>all the files in the box will be saved on the server. Something like GMail.
>But the problem already starts at beginning because I don't know how to open
>File Browser via JS. Can someone help me? After that I tought I would make
>for every file it's own <input type="file"> tag.It will be hidden of course.
>Is this the correct way?
>
>Bye,
>
>Iztok
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>
>__________________________________________________________
>This message was scanned by ATX
>1:47:28 PM ET - 11/28/2004




More information about the Javascript mailing list