[thelist] File upload

.jeff jeff at members.evolt.org
Wed Jan 22 01:39:01 CST 2003


please make it a point to trim your posts in the future.

now, on to your question.

> From: Stevenson Ngila
> So is there a way in javascript that one can create an
> input tag of type file and attach a file to it hence
> using the field name while uploading in cold fusion?

ok, lemme just say right up front that you can't set the value of a file
input via html or javascript.  the only way to get a value into the field is
for the user to do it by either typing or pasting a path to a file into the
field or by picking a file from the browse dialog.  this is for security
purposes so a less than ethical developer couldn't set the display of a file
input to none/hidden, set the value of the file input to the path of some
important file on the user's machine.

so, the solutions are few and complicated.

1)  ask the user how many files they'll be uploading
    and then with javascript/dhtml or server-side
    generate the appropriate number of fields and
    leave it to the user to use them all and not
    duplicate any paths.

2)  give the user a single file input and let them
    use it over and over again, uploading a single
    file at a time until they're all uploaded.  if
    you're lucky they won't upload the same file
    multiple times and won't forget any of the files
    they meant to upload.

3)  use something other a file input to get the files
    to the server.  i have experience with an activex
    control that works quite well.  it's quite
    configurable and, despite claims by the developers,
    doesn't require any special component on the server
    to work.  the downside is that this isn't a very
    feasible solution in alot of applications.  most
    likely you'll only get this sort of thing to float
    in a controlled environment like an admin for a web
    site or an intranet.  additionally, the activex
    control i use is not free (though very reasonably

4)  say screw it with using a form to upload multiple
    files and give the user ftp access.  the downside
    is an additional service running on the server that
    can be compromised.  however, it's free and even
    removes the need to build file management tools
    into your system -- list, rename, delete, move, etc.

5)  quit your web job and get a gig with a traveling
    circus.  could probably make good money as most of
    us web folk are sideshow freaks in our own right
    anyway.  the downside is having to share a bed with
    either the bearded lady or the guy with 300
    piercings.  however, the upside would be the beer
    drinking competitions each night even though the
    midgets always seem to win.

imo, 3 has a slight edge over 5 hence why i'm still here to write this
response to your poser.

good luck,


jeff at members.evolt.org

More information about the thelist mailing list