UploadifyForm.cshtml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. @{
  2. ViewBag.Title = "UploadifyForm";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <link href="~/Content/scripts/plugins/uploadify/uploadify.css" rel="stylesheet" />
  6. <link href="~/Content/scripts/plugins/uploadify/uploadify.extension.css" rel="stylesheet" />
  7. <script src="~/Content/scripts/plugins/uploadify/jquery.uploadify.min.js"></script>
  8. <script>
  9. var folderId = request('folderId');
  10. $(function () {
  11. uploadify();
  12. })
  13. //上传文件
  14. function uploadify() {
  15. $("#uploadify").uploadify({
  16. method: 'post',
  17. uploader: '/PublicInfoManage/ResourceFile/UploadifyFile?folderId=' + folderId,
  18. swf: top.contentPath + '/Content/scripts/plugins/uploadify/uploadify.swf',
  19. buttonText: "添加文件",
  20. height: 30,
  21. width: 90,
  22. fileTypeExts: '*.avi;*.mp3;*.mp4;*.bmp;*.ico;*.gif;*.jpeg;*.jpg;*.png;*.psd; *.rar;*.zip;*.swf;*.log;*.pdf;*.doc;*.docx;*.ppt;*.pptx;*.txt; *.xls; *.xlsx;',
  23. removeCompleted: false,
  24. onSelect: function (file) {
  25. $("#" + file.id).prepend('<div style="float:left;width:50px;margin-right:2px;"><img src="/Content/images/filetype/' + file.type.replace('.', '') + '.png" style="width:40px;height:40px;" /></div>');
  26. $('.border').hide();
  27. },
  28. onUploadSuccess: function (file) {
  29. $("#" + file.id).find('.uploadify-progress').remove();
  30. $("#" + file.id).find('.data').html(' 恭喜您,上传成功!');
  31. $("#" + file.id).prepend('<a class="succeed" title="成功"><i class="fa fa-check-circle"></i></a>');
  32. Loading(false);
  33. $.currentIframe().$("#gridTable").trigger("reloadGrid");
  34. Loading(false);
  35. },
  36. onUploadError: function (file) {
  37. $("#" + file.id).removeClass('uploadify-error');
  38. $("#" + file.id).find('.uploadify-progress').remove();
  39. $("#" + file.id).find('.data').html(' 很抱歉,上传失败!');
  40. $("#" + file.id).prepend('<span class="error" title="失败"><i class="fa fa-exclamation-circle"></i></span>');
  41. }
  42. });
  43. $("#uploadify-button").prepend('<i style="opacity: 0.6;" class="fa fa-cloud-upload"></i>&nbsp;');
  44. //$(document).scrollTop(300);
  45. }
  46. </script>
  47. <div style="margin: 10px">
  48. <div style="height: 38px;">
  49. <div style="float: right; line-height: 26px; color: #337ab7; cursor: pointer; position: relative;">
  50. 上传必知
  51. </div>
  52. <input id="uploadify" name="uploadify" type="file" />
  53. </div>
  54. <div class="border" style="height: 295px; border-radius: 5px;">
  55. <div class="drag-tip" style="text-align: center; padding-top: 100px;">
  56. <h1 style="color: #666; font-size: 20px; font-family: Microsoft Yahei; padding-bottom: 2px;">试试将电脑里的文件拖拽到此上传</h1>
  57. <p style="color: #666; font-size: 12px;">
  58. (您的浏览器不支持此拖拽功能)
  59. </p>
  60. </div>
  61. </div>
  62. </div>