Guest User

Untitled

a guest
Nov 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. var obj = $('#fileupload');
  2. var _width=0;
  3. var _height=0;
  4. if(obj && obj.length>0) {
  5. obj.fileupload({
  6. autoUpload: false,//是否自动上传
  7. url: url,//上传地址
  8. dataType: 'json',
  9. pasteZone:$('#fileupload'),
  10. add:function (e, data) {
  11. var id=$(this).attr("id");
  12. if(id=="fileupload"){
  13. _width=$('#adImgWidth').text();
  14. _height=$('#adImgheight').text();
  15. }
  16. $(this).fileupload({
  17. url: url+"?width="+_width+"&height="+_height
  18. });
  19. loadImage(data.files[0],function(img) {
  20. if(img.width!=parseInt(_width)||img.height!=parseInt(_height)){
  21. showMessageDailog("警告","图片尺寸大小不符,请根据上传图片要求重新上传!");
  22. return;
  23. }else{
  24. data.submit();
  25. }
  26. });
  27. if(isIE8!=undefined&&isIE8){
  28. data.submit()
  29. }
  30. },
  31. done: function (e, data) {//设置文件上传完毕事件的回调函
  32. var imgName=data.result.imgName;
  33. if(imgName=="Error"){
  34. showMessageDailog("警告","图片尺寸大小不符,请根据上传图片要求重新上传!");
  35. }
  36. var imgUrl = data.result[0].url;//全路径
  37. var imgPath = data.result[0].imgPath;//相对路径
  38. var no = this.id.substring(this.id.length,this.id.length-1);
  39. if(imgUrl != ""){
  40. $("#resUrl"+no).val(imgUrl);
  41. //$("#imgPath"+no).val(imgUrl);
  42. //$("#imageSize").html(" 图片尺寸大小为  "+imgWidth +"*" +imgHeight+"  PX");
  43. }
  44. }
  45. }).bind('fileuploaddrop', function (e, data) {return false;});
  46. }
Add Comment
Please, Sign In to add comment