图片上传压缩
<script type="text/javascript"> var img = { Imgsource: [], } $(function () { $(".addimg").click(function () { $("#uploadFile").click(); }); $('#uploadFile').localResizeIMG({ //width: 100, quality: 0.7, success: function (result) { //var img = new Image(); //img.src = result.base64; showXY(result.base64); // $('body').append(img); // console.log(result); } }); //$("#uploadFile").change(function () { // var file = this.files[0]; // if (window.FileReader) { // var reader = new FileReader(); // reader.readAsDataURL(file); // //监听文件读取结束后事件 // reader.onloadend = function (e) { // showXY(e.target.result, file.fileName); // }; // } //}); $("#<%=top.ClientID%>_Person").click(function () { var title = $("#title").val(); var content = $("#content").val(); if (title.length > 0 && content.length > 0) { $.ajax({ //要用post方式 type: "Post", //方法所在页面和方法名 url: "TripAdd.aspx", data: { act: "add", Img: img.Imgsource, title: title, content: content, id: '<%=TripId%>' }, dataType: "json", success: function (data) { //提交成功 if (data.isSuc == "1") { window.location = 'TripList.aspx'; } }, }); } }); }); function showXY(source) { $(".addimg").before(" <li class=\"cbox\"><img src=\"" + source + "\" alt=\"\"></li>"); img.Imgsource.push(source.substr(source.indexOf(',') + 1)); } </script>