<input id="file" name="file_upload" type="file" style="display:none">
<a id="open_upload" href="#">upload file</a>
I want to open the <input type="file"> when I click "upload file".
any ideas?
upload file
Started by leeyo, Jul 19 2010 02:08 AM
4 replies to this topic
#1
Posted 19 July 2010 - 02:08 AM
|
|
|
#2
Posted 19 July 2010 - 02:42 AM
This should work, plug the onLoad into your <body> tag and the rest should work:
<body onLoad="document.getElementById('filebox').style.visibility = 'hidden';">
<a id="open_upload" href="#" onClick="document.getElementById('filebox').style.visibility = 'visible';">upload file</a>
<input type="file" id="filebox">
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#3
Posted 19 July 2010 - 03:14 AM
no.I don't want this.
I mean when click "upload file",and the file chosen dialog is open.don't need to click <input type="file">.
I mean when click "upload file",and the file chosen dialog is open.don't need to click <input type="file">.
#4
Posted 19 July 2010 - 04:23 AM
I think you mean you want to click on <a id="open_upload" href="#">upload file</a> and then the browse window opens, but the input type="file" remains hidden?
In that case it's only possible in IE doing something like:
Why not just remove the <a id="open_upload" href="#">upload file</a> and use the input type="file" only then?
In that case it's only possible in IE doing something like:
<head>
<style type="text/css">
.opaque {
visibility:hidden;
}
</style>
<script type="text/javascript">
function browse(){
var browse = document.getElementById('filebox');
browse.click();
}
</script>
</head>
<body">
<a id="open_upload" href="#" onClick="browse();">upload file</a>
<input type="file" id="filebox" class="opaque">
</body>Only IE supports the .click( )Why not just remove the <a id="open_upload" href="#">upload file</a> and use the input type="file" only then?
#5
Posted 19 July 2010 - 09:03 AM
Thanks oxano.
That's easy.thank you very much.
I saw this method in qq.com,it's different from i have ever seen.and it is specially and good looking.
That's easy.thank you very much.
I saw this method in qq.com,it's different from i have ever seen.and it is specially and good looking.


Sign In
Create Account


Back to top









