码迷,mamicode.com
首页 > Web开发 > 详细

获取上传图片路径方法

时间:2017-03-08 11:37:02      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:mozilla   comment   上传   null   window   chrome   logs   log   highlight   

        //获取上传图片路径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;
	}

 

获取上传图片路径方法

标签:mozilla   comment   上传   null   window   chrome   logs   log   highlight   

原文地址:http://www.cnblogs.com/AaronNotes/p/6518029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!