当前位置: 移动技术网 > IT编程>开发语言>c# > C#图片上传效果实例分析

C#图片上传效果实例分析

2019年07月18日  | 移动技术网IT编程  | 我要评论
本文实例讲述了c#图片上传效果实现方法。分享给大家供大家参考。具体如下: <%@ page title="" language="c#" m

本文实例讲述了c#图片上传效果实现方法。分享给大家供大家参考。具体如下:

<%@ page title="" language="c#" masterpagefile="~/default.master" autoeventwireup="true"
 codefile="default.aspx.cs" inherits="default" %>
<asp:content id="chead" contentplaceholderid="head" runat="server">
</asp:content>
<asp:content id="cbody" contentplaceholderid="contentplaceholder1" runat="server">
<asp:literal runat="server" id="ltrhtml"></asp:literal>
<script type="text/javascript">
    $().ready(function () {
       var counter = 0;
       $(function () {
         var btnupload = $('#addimage');
         new ajaxupload(btnupload, {
          action: 'saveupload.aspx',
          name: 'uploadfile',
           onsubmit: function (file, ext) {
             $("#loading").show();
           },
           oncomplete: function (file, response) {
             var uploadedfile = "userdata/" + file;
             $("#uploadimagewrapper").append("<div class='imagecontainer offset' id='current" + counter + "'><img height='65px' width='65px' src='" + uploadedfile + "' alt='" + uploadedfile + "'/><div id='close" + counter + "' class='close' title='" + uploadedfile + "' onclick='removeimage(this);'><a ></a></div></div>");
             $('#current' + counter).fadein('slow', function () {
              $("#loading").hide();
               $("#message").show();
               $("#message").html("added successfully!");
               $("#message").fadeout(3000);
               counter++;
             });
           }
         });
       });
    });
     function removeimage(_this) {
       var counter = _this.id.replace('close', '');
       $("#loading").show();
       $.ajax({
         type: "post",
         url: "removeupload.aspx",
         data: "filename=" + _this.getattribute('title'),
         success: function (msg) {
           $('#current' + counter).fadeout('slow', function () {
             $("#loading").hide();
             $("#message").show();
             $("#message").html("removed successfully!");
             $("#message").fadeout(3000);
           });
         }
       });
     }
   </script>
   <table id="imageuploader" cellpadding="0" cellspacing="0">
     <tr class="header">
       <td style="padding-left: 5px;">
         <a id="addimage" href="javascript:;">add image</a>
       </td>
     </tr>
     <tr class="body">
       <td valign="top">
         <div id="uploadimagewrapper">
         </div>
       </td>
     </tr>
     <tr class="footer">
       <td>
         <div id="loading" style="display: none">
           <table cellpadding="0" cellspacing="0">
             <tr>
               <td>
                 <img width="20" height="20" src="images/loading.gif" alt="loading..." />
               </td>
               <td>
                please wait...
               </td>
             </tr>
           </table>
         </div>
         <div id="message" style="color: green">
         </div>
       </td>
     </tr>
   </table>
 </asp:content>

希望本文所述对大家的c#程序设计有所帮助。

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网