JQ obtain input file picture displayed in the corresponding position

$('.c_showFile').on('change',function(){
				var c_showImg =this.files[0];
				getObjectURL(c_showImg);
			})

			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);
				}
				$('.file').css("background-image","url("+url+")");
				$('.file').css("background-size","100% 100%")
				return url;
			}

 

Compatibility not tested. You need to use a small partner use on demand.

Guess you like

Origin www.cnblogs.com/wxhhts/p/11897678.html