?
Solved

Custom BROWSE button caption in INPUT TYPE='FILE'

Posted on 2003-02-24
14
Medium Priority
?
14,094 Views
Last Modified: 2012-08-13
I am using the following HTML to upload a file

<form name="upload" action="catalogphoto.php" method="POST" enctype="multipart/form-data">
<table>
<tr><td><span>Select photo to upload:</span></td>
<td><input type="text" ID="imgfilename" readonly="1" value="">

<INPUT TYPE="file" ID="imgfile" NAME="imgfile" STYLE="display:none" onChange="imgfilename.value = this.value;">
<input type="button" onClick="imgfile.focus(); imgfile.click();" value="Choose image file..."></td></tr>

<tr><td colspan="2" align="right"><input type="submit" value="UPLOAD"></td></tr>
</table>
</form>

However it does NOT work in IE 6.0.2800.1106 on Win98SE.

When I press the submit button the value of imgfile file-type input is cleared and form is not posted. On second click no file is posted to server.
0
Comment
Question by:Zlatin Zlatev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
14 Comments
 
LVL 19

Accepted Solution

by:
webwoman earned 200 total points
ID: 8008601
You CANNOT change the button for that. Nor can you script it. Browser security prevents it.
0
 
LVL 8

Author Comment

by:Zlatin Zlatev
ID: 8008662
I was afraid of that... :(((
0
 
LVL 8

Author Comment

by:Zlatin Zlatev
ID: 8008700
Anyway I will kepp this open for 7 days if there is expert with a workaround suggestion. (hope dies last < grim > )
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:gator4life
ID: 8012010
Just for effect, I will second webwoman's response...you can't alter the "Browse..." button in any way.  You can't script it, you can't style it, etc.  It is impossible as of the current browsers go.  Maybe in future versions, they will at least give us an opportunity to style it, so that the file upload control can match overall styles schemes.

gator4life
(chomp, chomp)
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8012367
That code used to work because there was a security hole in IE (what else is new?) but it has been fixed and the behaviour of the browse button is back to what it is supposed to be.

Cd&

0
 
LVL 8

Author Comment

by:Zlatin Zlatev
ID: 8015073
Well I wanted to change the caption so that to have multiple languages of a page... And more descriptive caption. But I (and our customers) will live with "Browse" caption of the button.

It's shame that it cannot be styled and that there is no title, caption or whatever atribute for changing Browse button caption.

I am assigning the points to webwoman because she was first.

Kind Regards,
Zlatin Zlatev
0
 
LVL 8

Author Comment

by:Zlatin Zlatev
ID: 8015100
However if someone has a solution for this (even if it requires additional component) drop me a line here and I'll repost the question.
0
 

Expert Comment

by:ELECTRON
ID: 12502387
mmm///
0
 
LVL 8

Author Comment

by:Zlatin Zlatev
ID: 12507857
pardon? what kind of "hack"? how do you determine what is "hack" and what is not?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12514706
Anything that tricks the user to get around browser security is a hack and a violation of the user rights; and THAT KIND OF CODE IS NOT GOING BE ALLOWED ON THIS SITE.

COBOLdinosaur
Page Editor, Javascript
0
 
LVL 8

Author Comment

by:Zlatin Zlatev
ID: 12517998
OK I would like to know if there is a setting of browser security that will allow the user to use such a code. Suppose this code is used on a intranet...
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12518171
If you are on an intranet.  You use IEAK to customize the security settings and you can do pretty much anything you want, or you build a custom activeX control.  

Cd&
0
 

Expert Comment

by:dkattan
ID: 25173043
This is an outdated post, but styling an input=file is doable with some finesse. You wrap the <input type="file"> in another element, like a span, div, li, whatever. Set the container element to have an image background with the input file and browse button styled like you want it, then set the opacity of the <inpute type="file" /> to opacity=0; in your CSS. This makes the area look like your custom styling, but the user is actually clicking the transparent type=file input box.

This is a horrible explanation, but hopefully you get the idea.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question