upload_upyun.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <include file="./Application/Admin/View/head.html" />
  5. <style type="text/css">
  6. .citys{
  7. margin-bottom: 10px;
  8. }
  9. .citys p{
  10. line-height: 28px;
  11. }
  12. .warning{
  13. color: #c00;
  14. }
  15. table a{
  16. margin-right: 8px;
  17. color: #369;
  18. }
  19. .imgUpload {
  20. width: 60px;
  21. height: 25px;
  22. line-height: 25px;
  23. text-align: center;
  24. border-radius: 2px;
  25. background: #CC290E;
  26. color: #FFF;
  27. font-size: 12px;
  28. border: none;
  29. cursor: pointer;
  30. outline: none;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <article class="page-container">
  36. <form action="" method="post" class="form form-horizontal" id="form-admin-group-add">
  37. <notempty name="info.id">
  38. <div class="row cl">
  39. <label class="form-label col-xs-4 col-sm-3">ID:</label>
  40. <div class="formControls col-xs-8 col-sm-9">{$info.id}</div>
  41. </div>
  42. </notempty>
  43. <!--图片异步上传并预览1-->
  44. <div class="row cl">
  45. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>场馆名称:</label>
  46. <div class="formControls col-xs-8 col-sm-9">
  47. <input type="text" class="input-text imgInput" value="" placeholder="" name="img" style="width: 240px;" />
  48. <input type="button" class="imgUpload" value="上传" style="width: 50px;"/>
  49. <input type="file" style="display: none;" class="imgFile">
  50. <div class="imgView" style="margin-top: 10px;"></div>
  51. </div>
  52. </div>
  53. <!--图片异步上传并预览2-->
  54. <div class="row cl">
  55. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>场馆名称:</label>
  56. <div class="formControls col-xs-8 col-sm-9">
  57. <input type="text" class="input-text imgInput" value="" placeholder="" name="img" style="width: 240px;" />
  58. <input type="button" class="imgUpload" value="上传" style="width: 50px;"/>
  59. <input type="file" style="display: none;" class="imgFile">
  60. <div class="imgView" style="margin-top: 10px;"></div>
  61. </div>
  62. </div>
  63. </form>
  64. </article>
  65. <!--_footer 作为公共模版分离出去-->
  66. <include file="./Application/Admin/View/foot.html" />
  67. <!--/_footer /作为公共模版分离出去-->
  68. <script src="/Public/plugins/js/jquery.citys.js"></script>
  69. <script type="text/javascript">
  70. // $('#demo').citys({code:<?php echo($res['address_code']);?>});
  71. </script>
  72. <script>
  73. //下面js课用于多个图片异步上传,无需重复
  74. $(document).on('click','.imgUpload',function(){
  75. $(this).siblings('.imgFile').trigger('click');
  76. });
  77. $(document).on('change','.imgFile',function(e){
  78. var imgFile = $(this);
  79. var reader = new FileReader();
  80. reader.onload = (function (file) {
  81. return function (e) {
  82. var imgBase64 = this.result;
  83. var html = '<img src="' + imgBase64 + '" style="width:240px;height:auto;" >';
  84. $(imgFile).siblings('.imgView').html(html);
  85. $.ajax({
  86. type: "post",
  87. url: "/Admin/common/upload_upyun",
  88. dataType:'json',
  89. data: {
  90. img: imgBase64
  91. },
  92. success: function(data) {
  93. if (data.status == '1') {
  94. $(imgFile).siblings('.imgInput').val(data.info);
  95. }
  96. }
  97. });
  98. };
  99. })(e.target.files[0]);
  100. reader.readAsDataURL(e.target.files[0]);
  101. });
  102. </script>
  103. </body>
  104. </html>