【问题标题】:File Upload button not working in Safari文件上传按钮在 Safari 中不起作用
【发布时间】:2014-01-02 20:59:36
【问题描述】:

我的页面中有文件上传字段。它在 chrome 和 firefox 上运行良好,但在 safari 中却无法运行。

代码:

  <label>
            <div>
                <img id="blah" src="../images/picture.png"/><br>
                <span style="color:#4291ce">Add Logo</span></div>
                <span style="display: none;">><input type='file' onchange="readURL(this);" name="userfile"  id = "userfile" style="opacity: 0; cursor: pointer; -moz-opacity: 0; filter: alpha(opacity=0);"/></span>          
        </label>



function readURL(input) {
if (input.files && input.files[0]) {
    var reader = new FileReader();
    reader.onload = function(e) {
        $('#blah').attr('src', e.target.result);
    }
    reader.readAsDataURL(input.files[0]);
    }
} 

【问题讨论】:

  • 那么会发生什么呢?

标签: jquery html safari


【解决方案1】:

请注意,您将面临与 IE9 相同的问题-(由于安全性),您必须将输入文件设置为相对的,不透明度为零,字体大小等于绝对 div 的高度。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多