V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Air_Mu
V2EX  ›  问与答

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

  •  
  •   Air_Mu · Apr 8, 2013 · 11274 views
    This topic created in 4771 days ago, the information mentioned may be changed or developed.
    如:
    <input id="fish" type="file">

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

    GOOGLE了半天也没发现能成功解决方案。请教
    3 replies    1970-01-01 08:00:00 +08:00
    zhangxiao
        1
    zhangxiao  
       Apr 8, 2013
    以前我也研究过,记得是没有办法的… 因为安全问题禁止了从浏览器里记录用户硬盘路径的可能性吧
    weizhenye
        2
    weizhenye  
       Apr 8, 2013   ❤️ 1
    用File API
    http://antimatter15.github.io/player/player.html
    这个可以播放本地音乐
    是用window.createBlobURL(file)之类的得到Blob路径
    Kaiyuan
        3
    Kaiyuan  
       Apr 9, 2013
    @weizhenye 这样我的坑( https://github.com/Kaiyuan/Air-Play-Box )就可以填了,之前一直找不到方法。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2430 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 15:43 · PVG 23:43 · LAX 08:43 · JFK 11:43
    ♥ Do have faith in what you're doing.