470,811 Members | 1,113 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,811 developers. It's quick & easy.

file field

Hi,
In the file field <input type="file" name="file1">, can I modify the button
"Browse..."?
I want to hide the file field but show a button like "Open". When I click on
this button, it catches a file, and use onchange even to upload this file.
thanks for any idea.
Atse

Jul 19 '05 #1
4 3786
I'm afraid you can't modify that button in current browsers

IIRC, though, there are tricks you can do with CSS layers which might be
able to mask it...
--
Atrax, MVP, IIS

http://rtfm.atrax.co.uk/

"atse" <du******@yahoo.com> wrote in message
news:oo**********************@news01.bloor.is.net. cable.rogers.com...
Hi,
In the file field <input type="file" name="file1">, can I modify the button "Browse..."?
I want to hide the file field but show a button like "Open". When I click on this button, it catches a file, and use onchange even to upload this file.
thanks for any idea.
Atse

Jul 19 '05 #2
Hi, Atse

Please see the code bellow. It uses customized button, you can also use
an image or other HTML element to browse files.
There is one difference with this code and plain type=file field -
client must select file from browse window, cannot copy full path to the
text field.
Antonin
See Pure/Huge ASP upload (http://www.pstruh.cz) to accept uploaded file
in ASP :-)

<HTML>
<HEAD>
<TITLE></TITLE>
<Script Language='Javascript'>
function validateFile()
{
document.frm.Image.click();
var sTmpString = new String(document.frm.Image.value);

var iPos = sTmpString.lastIndexOf("\\");

document.frm.txt.value = sTmpString.substring(iPos+1,sTmpString.length);

}
</Script>
</HEAD>
<BODY>
<form name="frm">
<input type="file"
name="Image" size="20"
onChange="validateFile();" style="visibility:hidden;">
<input type="text" name="txt">
<input type="button" value="Browse ..."
onMouseDown="validateFile();">
</form>
</BODY>
</HTML>

"atse" <du******@yahoo.com> wrote in message
news:oo**********************@news01.bloor.is.net. cable.rogers.com...
Hi,
In the file field <input type="file" name="file1">, can I modify the button "Browse..."?
I want to hide the file field but show a button like "Open". When I click on this button, it catches a file, and use onchange even to upload this file.
thanks for any idea.
Atse

Jul 19 '05 #3
Thanks Antonin, but it doesn't work for me, because no file is passed to
upload. I enable Image's visibility, and found the path there. When I click
on the submit button once, the path is clear on the Image field, and the
form doesn't submit. In another word, click once the submit button, the form
doesn't submit, but the Image field is clear the path. Any idea?
atse

"Antonin Foller" <an*****@foller.cz> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
Hi, Atse

Please see the code bellow. It uses customized button, you can also use an image or other HTML element to browse files.
There is one difference with this code and plain type=file field -
client must select file from browse window, cannot copy full path to the
text field.
Antonin
See Pure/Huge ASP upload (http://www.pstruh.cz) to accept uploaded file in ASP :-)

<HTML>
<HEAD>
<TITLE></TITLE>
<Script Language='Javascript'>
function validateFile()
{
document.frm.Image.click();
var sTmpString = new String(document.frm.Image.value);

var iPos = sTmpString.lastIndexOf("\\");

document.frm.txt.value = sTmpString.substring(iPos+1,sTmpString.length);

}
</Script>
</HEAD>
<BODY>
<form name="frm">
<input type="file"
name="Image" size="20"
onChange="validateFile();" style="visibility:hidden;">
<input type="text" name="txt">
<input type="button" value="Browse ..."
onMouseDown="validateFile();">
</form>
</BODY>
</HTML>

"atse" <du******@yahoo.com> wrote in message
news:oo**********************@news01.bloor.is.net. cable.rogers.com...
Hi,
In the file field <input type="file" name="file1">, can I modify the button
"Browse..."?
I want to hide the file field but show a button like "Open". When I click on
this button, it catches a file, and use onchange even to upload this

file. thanks for any idea.
Atse


Jul 19 '05 #4
Tom
Yes, the browser doesn't allow this. Although you might be able to
hide the input with a layer or something, you won't be able to pre-set
the file that you want uploaded. You need to use an applet or other
client control like ActiveX to supplement the browser security
limitations.
-Tom
"Atrax" <at***@dontspamatrax.co.uk> wrote in message news:<u3**************@TK2MSFTNGP09.phx.gbl>...
I'm afraid you can't modify that button in current browsers

IIRC, though, there are tricks you can do with CSS layers which might be
able to mask it...
--
Atrax, MVP, IIS

http://rtfm.atrax.co.uk/

"atse" <du******@yahoo.com> wrote in message
news:oo**********************@news01.bloor.is.net. cable.rogers.com...
Hi,
In the file field <input type="file" name="file1">, can I modify the

button
"Browse..."?
I want to hide the file field but show a button like "Open". When I click

on
this button, it catches a file, and use onchange even to upload this file.
thanks for any idea.
Atse

Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Karen Grube | last post: by
1 post views Thread by Monte Chan | last post: by
2 posts views Thread by Robert | last post: by
8 posts views Thread by yinjennytam | last post: by
6 posts views Thread by Richard | last post: by
15 posts views Thread by lxyone | last post: by
8 posts views Thread by Tommy Grav | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.