Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove text field from HTML file input

Normally, a file upload dialog is invoked by clicking the button created by <input type="file"/>. But then, I don't want the text field that comes with it. Is there a way to get rid of the text field? Or is there an alternative way to open the file upload dialog without using <input/>?

like image 487
Dave Avatar asked Sep 13 '25 08:09

Dave


2 Answers

Add file input, and set its position to quite far away.
Add a button. Set buttons onclick to $("#myFile").click(); :D

<input id="myFile" name="file" type="file" style="position:absolute;left:-10000px;top:-10000px;">

<button onclick="$('#myFile').click();">Browse</button>
like image 90
Ferid Gürbüz Avatar answered Sep 15 '25 23:09

Ferid Gürbüz


agree with alex

<style>
.file_wrap{
    background:url(file.jpg);
    overflow:hidden;
    width:30px;
    height:10px;
}
.file_wrap input{
    opacity:0;
    font-size:999px;
    cursor:pointer;
}
</style>
<div class="file_wrap">
   <input type="file" />
</div>
like image 21
diablero13 Avatar answered Sep 15 '25 22:09

diablero13