Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use image input type file? 2

Status
Not open for further replies.

shu745

Programmer
May 14, 2001
79
US
Hey all, I was hoping there was a way to use an image to essecially do the same thing as <input type="file">. I haven't seen it done before so I'm not sure if it's possible.
I was hoping thru javascript we could do sumething like:

function browseFile() {
whatever code needed to do the file upload stuff
}
....
<img onClick="browseFile()" />

I just want the button to look pretty. Any help is appreciated.

-Shu
 
Code:
<form name="fn">
<input type="file" name="f_input">
<input type="image" src="Band Picture.JPG" name="i_input" onclick="document.fn.f_input.click();return false;">
</form>

However, it's IE only (and maybe also Opera). Not just that, but IE pops up a security warning about ActiveX controls the first time you click the link. Not really worth the trouble, in my opinion. And setting the background-image for a file input doesn't work, either. I don't think it's doable.

Rick

 
The background image doesn't work nor does css on the input type file. RISTMO, thanks for the code, but i guess i'll just have to settle.

Thanks for the input.
- Shu
 
CliveC: Thank you for your reply but I just wanted to style my input type file button using css styles or an image, not submit the form using an image.

wing2x: THANK YOU for your reply. This info seems very helpful! You get a star. =)

- Shu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top