获取上传图片路径方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取上传图片路径方法相关的知识,希望对你有一定的参考价值。

        //获取上传图片路径1
	function fileComment(obj){
		/*获取input=file图片路径*/
		var objUrl = getObjectURL(obj.files[0]);
		if (objUrl) {
			return objUrl;
		}
	}
	//获取上传图片路径2
	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;
	}

 

以上是关于获取上传图片路径方法的主要内容,如果未能解决你的问题,请参考以下文章