Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var obj = $('#fileupload');
- var _width=0;
- var _height=0;
- if(obj && obj.length>0) {
- obj.fileupload({
- autoUpload: false,//是否自动上传
- url: url,//上传地址
- dataType: 'json',
- pasteZone:$('#fileupload'),
- add:function (e, data) {
- var id=$(this).attr("id");
- if(id=="fileupload"){
- _width=$('#adImgWidth').text();
- _height=$('#adImgheight').text();
- }
- $(this).fileupload({
- url: url+"?width="+_width+"&height="+_height
- });
- loadImage(data.files[0],function(img) {
- if(img.width!=parseInt(_width)||img.height!=parseInt(_height)){
- showMessageDailog("警告","图片尺寸大小不符,请根据上传图片要求重新上传!");
- return;
- }else{
- data.submit();
- }
- });
- if(isIE8!=undefined&&isIE8){
- data.submit()
- }
- },
- done: function (e, data) {//设置文件上传完毕事件的回调函
- var imgName=data.result.imgName;
- if(imgName=="Error"){
- showMessageDailog("警告","图片尺寸大小不符,请根据上传图片要求重新上传!");
- }
- var imgUrl = data.result[0].url;//全路径
- var imgPath = data.result[0].imgPath;//相对路径
- var no = this.id.substring(this.id.length,this.id.length-1);
- if(imgUrl != ""){
- $("#resUrl"+no).val(imgUrl);
- //$("#imgPath"+no).val(imgUrl);
- //$("#imageSize").html(" 图片尺寸大小为 "+imgWidth +"*" +imgHeight+" PX");
- }
- }
- }).bind('fileuploaddrop', function (e, data) {return false;});
- }
Add Comment
Please, Sign In to add comment