html input选择文件后将文件转为地址

function getObjectURL(file)
{
    var url = null;
    if (window.createObjectURL != undefined)
    { // basic
         url = window.createObjectURL(file);
     } else if (window.URL != undefined)
     {
         // mozilla(firefox)
         url = window.URL.createObjectURL(file);
    } else if (window.webkitURL != undefined) {
         // webkit or chrome
         url = window.webkitURL.createObjectURL(file);
    }
    return url;
}

var objUrl = getObjectURL($('#file').files[0]);
 

格式: blog:http://url/token

 
posted @ 2021-06-18 09:57  study_php_java_C++  阅读(373)  评论(0编辑  收藏  举报