2011-11-23 43 views
5

我使用jQuery MultiFile插件。下面的上传按钮:jQuery MultiFile选择文件按钮

Choose File button

我可以改变选择文件文本别的东西?网上冲浪不能帮助我。

我只想要一个“选择文件”。

请只说*是(+以及如何)或*否。

谢谢!

+0

[标签文件上传按钮(http://stackoverflow.com/questions/686905/labeling-file-upload-button) – Piskvor

回答

2

不,这是<input type="file">控件的一部分,网页无法控制其外观。

+0

这里的一些变通办法的可能重复: http://stackoverflow.com/questions/686905/labeling-file-upload-button – malletjo

+0

@racar:这确实是一个黑客 - 一个相当丑陋的黑客,恕我直言;它会被标记为clickjacking(因为它是无论如何):http://www.gnucitizen.org/blog/more-advanced-clickjacking-ui-redress-attacks/感谢您指出重复,但。 – Piskvor

+0

我明白了。我可以隐藏文件控件,并通过jquery/javascript“激活”它吗? – Vitalyp

3

是的,我找到了最好的解决方法!这不是黑客 - 我们只需要2个按钮:原创和'假'。

<input type="button" value="Choose Files"> 
    <input type="file"> 

假被显示给用户,并且具有

z-index:1 

原件被放置在其上方,具有

z-index:2, opacity: 0; position: relative; 

并且具有回调:

:onmousedown=>"buttonPush('depressed')", :onmouseup=>"buttonPush('normal')" 

    function buttonPush(buttonStatus) { 
    if (buttonStatus == "depressed") 
     document.getElementById("fake_btn").style.borderStyle = "inset"; 
    else 
     document.getElementById("fake_btn").style.borderStyle = "outset"; 
    } 

由于这种链接 http://www.dreamincode.net/forums/topic/15621-styling-a-file-browse-button/

问候@Piskvor,@racar

+0

你摇滚!添加style =“visibility:hidden”到文件按钮,你是金。 – JStark