V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Air_Mu
V2EX  ›  问与答

Chrome下如何获取input:file里的文件在硬盘上的路径?

  •  
  •   Air_Mu · 2013-04-08 01:54:34 +08:00 · 10530 次点击
    这是一个创建于 4007 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如:
    <input id="fish" type="file">

    $('#fish').change(function(){
    alert($(this).val());
    });
    据说低版本IE上这样能获得路径,但是为了安全,现代浏览器都隐藏了路径,比如CHROME会得到X://fakepath/文件名的结果。

    GOOGLE了半天也没发现能成功解决方案。请教
    3 条回复    1970-01-01 08:00:00 +08:00
    zhangxiao
        1
    zhangxiao  
       2013-04-08 02:54:35 +08:00
    以前我也研究过,记得是没有办法的… 因为安全问题禁止了从浏览器里记录用户硬盘路径的可能性吧
    weizhenye
        2
    weizhenye  
       2013-04-08 21:27:18 +08:00   ❤️ 1
    用File API
    http://antimatter15.github.io/player/player.html
    这个可以播放本地音乐
    是用window.createBlobURL(file)之类的得到Blob路径
    Kaiyuan
        3
    Kaiyuan  
       2013-04-09 11:04:22 +08:00
    @weizhenye 这样我的坑( https://github.com/Kaiyuan/Air-Play-Box )就可以填了,之前一直找不到方法。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3239 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 12:11 · PVG 20:11 · LAX 05:11 · JFK 08:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.