【问题标题】:Upload File - Customizing Html上传文件 - 自定义 Html
【发布时间】:2012-11-28 01:34:41
【问题描述】:
当我点击“上传”按钮时如何浏览我的文件?
我需要创建一个隐藏文件输入吗?
更多解释:
我无法编辑我的 html 表单的输入类型文件的 css。所以在每个浏览器中我都有不同的布局。我不想要它。我想自定义我的表单。
我创建了一个按钮。当我点击按钮时,我想出现文件选择屏幕。
当我选择文件并按 ok 时,我想将文件的路径字符串放入我创建的输入中。
【问题讨论】:
标签:
javascript
html
css
file
upload
【解决方案1】:
我用这段代码解决了我的问题:
<div class="input-append">
<label for="showpath">File Upload:</label>
<input id="showpath" type="text" onclick ="javascript:document.getElementById('CommentFile').click();"/>
<button type="button" onclick ="javascript:document.getElementById('CommentFile').click();"></button>
<input type="file" name="data[Comment][file]" id="CommentFile" style='visibility: hidden;' onchange="updateInput(this.value,'showpath')"/>
</div>
【解决方案2】:
<input type='file' />
更多信息请访问w3schools。
【解决方案3】:
您能提供更多信息吗?您需要使用file html 表单元素。
file 元素让您可以自然地浏览本地文档。
要处理文件附件,您需要了解一种编程语言,例如php