[thelist] Styling <input type="file">

Jeff Howden jeff at jeffhowden.com
Sun Dec 14 15:53:36 CST 2003


dan,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Dan Williams
>
> So, my alternative plan is this. I create a normal text
> box and button, styled the way I want, and make the file
> box invisible. Then, when my button is clicked, I
> trigger the file box button, and once the result has
> come back, I update the textbox with this. Similarly,
> every time the text box is changed, I update the file
> box.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

and when you post the form, the file won't upload to the server.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> My question is basically, is this a good idea?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

no, it's a very, very bad idea and you will fail.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> ...is there a way to properly style the file box, that
> I am missing?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

nope.  there really isn't a way to style a file input.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> And also, how to I trigger the Browse button of the
> file box?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

fire the click event on the file input.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> I assume that the file box supports onchange, [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

it does not.  the file input only supports onclick, onfocus, and onblur.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> so when either one triggers an onchange event, I'll
> update the value property of the other.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

the value of a file input is read-only.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Ideas?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

yeah, walk away from this notion of styling a file input.  it can't be done
and still have a working file upload.

.jeff

------------------------------------------------------
Jeff Howden - Web Application Specialist
Resume - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/



More information about the thelist mailing list