自定义浏览按钮上传文件

时间:2013-03-07 02:52:41

标签: javascript

您好我目前有自定义2按钮,名为浏览和导入。我还有一个输入类型作为文本。我的问题是如何浏览和选择记录并放入输入类型文本

请告知

<input type="button" id="btnBrowse" value="Browse" onclick="document.getElementById('fileID').click(); return false" style="height:31px; font-size:14px; background-color:#3399FF" class="k-button" />
       <input type="submit" id="btnSubmit" value="Import" style="height:31px; font-size:14px; background-color:#3399FF" class="k-button" />
       <input type="text" id="fileName" class="file_input_textbox" readonly="readonly">

3 个答案:

答案 0 :(得分:3)

但是,您可以自定义几乎任何其他html元素。 这是一个完整的解决方案:

<input id="btn" type="file" style="display:none;" onchange="document.getElementById('file').value=this.value.substring(this.value.lastIndexOf('\\')+1);">

<input id="file" type="text" style="width:200px;">

<input type="button" onclick="document.getElementById('btn').click();" value="click me" />

答案 1 :(得分:1)

当然你可以设置文件输入按钮的样式。在SO上已经覆盖了这个,一遍又一遍。例如,Labeling file upload button

答案 2 :(得分:0)

你可以使用

<input type="file"/>
相关问题