upload-min.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var osshost = '';
  2. function WebUploadJs(tagId, path, resize, size, func) {
  3. var max_size = size.max_file_size / 1024;
  4. var resize_json = JSON.stringify(resize);
  5. if (resize.width == 0 && resize.height == 0 && resize.quality == 0) {
  6. upload.render({
  7. elem: '#' + tagId.replace('Btn', '') + 'Btn',
  8. url: '/Api/PublicMethod/LayUIUpload',
  9. data: {
  10. Path: path
  11. },
  12. multiple: false,
  13. accept: 'file',
  14. exts: 'doc|docx|xls|xlsx',
  15. size: max_size.toFixed(2),
  16. before: function (obj) {
  17. obj.preview(function (index, file, result) {
  18. // func(result);
  19. });
  20. },
  21. done: function (res) {
  22. func(res.data);
  23. }
  24. });
  25. } else {
  26. upload.render({
  27. elem: '#' + tagId.replace('Btn', '') + 'Btn',
  28. url: '/Api/PublicMethod/LayUIUpload',
  29. data: {
  30. Path: path,
  31. Resize: resize_json
  32. },
  33. multiple: false,
  34. size: max_size.toFixed(2),
  35. before: function (obj) {
  36. obj.preview(function (index, file, result) {
  37. // func(result);
  38. });
  39. },
  40. done: function (res) {
  41. func(res.data);
  42. }
  43. });
  44. }
  45. }