使用说明:新建文件,直接复制粘贴,保存文件为html 格式,在浏览器运行即可;
第一种:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> New Document </title> </head> <script src="http://i.gtimg.cn/qzone/biz/gdt/lib/jquery/jquery-2.1.4.js?max_age=31536000"></script> <script> $(function(){ $('#upLoad').on('change',function(){ var filePath = $(this).val(), //获取到input的value,里面是文件的路径 fileFormat = filePath.substring(filePath.lastIndexOf(".")).toLowerCase(), imgBase64 = '', //存储图片的imgBase64 fileObj = document.getElementById('upLoad').files[0]; //