change the text of browse button in file upload control

L

lale.kat

Hi.I want to change the text of browse button in file upload control
in firfox,for example insted of being "browse" be "upload file", how
can I do that?
Is it possible ?I found a code that only works in IE but it doesent
work in fireFox, I want to work in both of them.

<html>
<head>
<title>File Upload Example</title>
<script language="JavaScript" type="text/javascript">
function HandleFileButtonClick()
{
document.frmUpload.myFile.click();
document.frmUpload.txtFakeText.value =
document.frmUpload.myFile.value;
}
</script>
</head>
<body>
<form name="frmUpload" encType="multipart/form-data">
<!-- Real Input field, but hidden-->
<input type="file" name="myFile" style="display: none">
<!-- Fake field to fool the user -->
<input type="text" name="txtFakeText" readonly="true">
<!-- Button to invoke the click of the File Input -->
<input type="button" onclick="HandleFileButtonClick();"
value="Upload File" >
</form>
</body>
</html>
-----------------
 
S

Steve Swift

Hi.I want to change the text of browse button in file upload control
in firfox,for example insted of being "browse" be "upload file", how
can I do that?

They've gone to a lot of trouble to stop me using the mechanism you're
looking for to build a website that tells you to enter the file
containing all your bank details then pressing the "Encrypt" button.
 
K

Kailash Nadh

Hi.I want to change the text of browse button in file upload control
in firfox,for example insted of being "browse" be "upload file", how
can I do that?
Is it possible ?I found a code that only works in IE but it doesent
work in fireFox, I want to work in both of them.

<html>
<head>
<title>File Upload Example</title>
<script language="JavaScript" type="text/javascript">
function HandleFileButtonClick()
{
document.frmUpload.myFile.click();
document.frmUpload.txtFakeText.value =
document.frmUpload.myFile.value;
}
</script>
</head>
<body>
<form name="frmUpload" encType="multipart/form-data">
<!-- Real Input field, but hidden-->
<input type="file" name="myFile" style="display: none">
<!-- Fake field to fool the user -->
<input type="text" name="txtFakeText" readonly="true">
<!-- Button to invoke the click of the File Input -->
<input type="button" onclick="HandleFileButtonClick();"
value="Upload File" >
</form>
</body>
</html>
-----------------

It is not possible to tamper with the Browse button for security
reasons. But if you are that desperate, well, you could try using a
Flash to upload files :)
http://www.flash-db.com/Tutorials/upload/upFiles.php
 
V

VK

It is not possible to tamper with the Browse button for security
reasons.

It is well possible to do using CSS/JavaScript or just CSS: see the
link I posted. Also in IE7 input type="file" is now finally treated as
two separate elements for styling: the input field and the button
itself. But if one needs not just styling but a custom button label as
well then he needs to stick to the linked solution. I personally would
offend to any label changes from the usability point of view, but
anyone is entitled to go to the hell by his own road :)
 
B

baig

I have used the above mentioned code in my application and it is
working fine; it perfectly wrapps the file controls but when I try to
submit the form it gives me this error dialog:

-----------------------------------
A Runtime Error has occured.
Do you wish to Debug?

Line 40
Error: Access is denied.

-----------------------------------

My application HTML and JS code is as follows:

----------------- JAVASCRIPT -------------------------

function uploadFiles(SUBJ_ID,SEV_ID,HELPDESK_ID,TRANS_ID)
{
document.myForm.encoding = "multipart/form-data";
document.myForm.action='test.jsp';
document.myForm.submit(); <------------------------------THIS IS
LINE 40
}


----------------- HTML -------------------------

<tr>

<td width="5%">
<a href="javascript:window.uploadFiles()" class="tablelink" >
<img src="Upload.jpg" >
</a>
</td>

<td width="94%">
<a name="ANCHOR_FILE_NAME">
<input type="file" name="FILE_NAME" style="display:
none;">
<input type="text" name="file">
<input type="button"
onClick="FILE_NAME.click();file.value=FILE_NAME.value;" value="Select
a File..." >
</a>
</td>

</tr>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top