代码之家  ›  专栏  ›  技术社区  ›  Rasool Ghafari

如何在没有扩展名[duplicate]的情况下检查javascript中的文件类型

  •  0
  • Rasool Ghafari  · 技术社区  · 7 年前

    0 回复  |  直到 12 年前
        1
  •  8
  •   epascarello    12 年前

    使用head请求进行Ajax调用。

    var url = window.location.href;
    var xhttp = new XMLHttpRequest();
    xhttp.open('HEAD', url);
    xhttp.onreadystatechange = function () {
        if (this.readyState == this.DONE) {
            console.log(this.status);
            console.log(this.getResponseHeader("Content-Type"));
        }
    };
    xhttp.send();