tags:

views:

104

answers:

3

I am wondering how to hide the text field portion of a standard html file upload tag

for example

<input type="file" name="somename" size="chars"> 

This generates obviously a text field and next to that field is a browse button... I want to hide the text field part but keep the button.

+6  A: 

I'd recommend hiding the whole thing and putting a separate button object which, when clicked, will end up clicking the input's browse button.

You can do this with CSS and javascript -- check out this article (actually the second time I've used this reference today).

Josh
Thanks this is exactly what I was looking for.
dswatik
A: 

You can put an image as a background for the button. That worked for me, a while ago.

ksemeks
A: 

The file input button is extremely difficult to style and manipulate, mainly for security reasons.

If you really need to customize your upload button, I recommend a Flash based uploader like SWFUpload or Uploadify that enables you to use a custom image as button, display a progress bar, and other things.

However, its basic philosophy differs from just embedding a control into a form. The uploading process takes place separately. Make sure you check out first whether this works for you.

Pekka
Thanks, but unfortunatly I am locked into the way my client designed the site.. which is a simple image button to bring up the file dialog.
dswatik
This could be done quite reliably using a Flash uploader. But if Shaun Inman's article works and degrades gracefully, that should do nicely.
Pekka