自定义文件上传按钮 [英] Custom file Upload Button
问题描述
< input type =file/>
可以选择从本地机器&进一步上传。
但是我想要一个自定义按钮,可以打开文件浏览器对话框
&通过点击定制按钮进一步上传。请参见下面的示例。让我们假设
<input type="file"/>
can give an option to select the file from local machine & upload further.
But i wanted a customized button which enables to open the file browser dialog
& further upload by clicking on customized button too. please see below the example. Let us assume
<input type="file" id="file-upload" /> /* file upload */
<input type="button" id="customized" /> /* simple button */
以下是jQuery fn&它允许按钮作为上传文件按钮。
following is the jQuery fn & it enables the button to works as upload file button.
$(function(){
$('#customized').click(function() { /* cutomized button clicked */
$('#file-upload').click(); /* Now file upload button auto clicked & file browser dialog opens. */
});
});
以上 js
在Windows机器上工作,而它不适用于Linux,为什么?
我也知道操作系统无关紧要,浏览器对此负责。请帮我解决这个问题
Windows
- - > mozila
IE
chrome
: 工作,请检查示例
above js
works on Windows machine while it doesn't work on Linux, Why?
also i know OS has nothing to do and Browser is responsible for this. Please help me to sort out this problem
Windows
- - > mozila
IE
chrome
: works, please check example
Linux
不适用于任何浏览器
Linux
not working on any browser
推荐答案
与浏览器版本而不是操作系统或浏览器。
This is more to do with the browser version rather than the OS or Browser make.
我相信在Windows上的Opera也会失败 - 因为某些浏览器阻止在文件类型输入上触发事件。
I believe this would also fail in Opera on Windows - as some browsers prevent the firing of events on a file-type input.
你可以做这个旧的CSS技巧 - http://www.quirksmode。 org / dom / inputfile.html
You could do this old CSS trick instead - http://www.quirksmode.org/dom/inputfile.html
这篇关于自定义文件上传按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!