【问题标题】:Checking the file extension and viewing the file in angularjs检查文件扩展名并在 angularjs 中查看文件
【发布时间】:2017-05-24 15:38:11
【问题描述】:

我必须检查上传文件的扩展名并在 angularjs 中查看。

我在 GET 响应中得到文件的 url。

感谢任何帮助。蒂亚!

【问题讨论】:

  • 那得到什么返回给你,将它插入你的问题以改进你的问题。

标签: javascript jquery html angularjs


【解决方案1】:

使用此函数从 GET URL 获取文件

function ext(url) {
// Remove everything to the last slash in URL
url = url.substr(1 + url.lastIndexOf("/"));

// Break URL at ? and take first part (file name, extension)
url = url.split('?')[0];

// Sometimes URL doesn't have ? but #, so we should aslo do the same for #
url = url.split('#')[0];

// Now we have only extension
return url;

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-11
    • 2013-02-27
    • 1970-01-01
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多