• C#通过flash实现在线上传


    引用

    1 <link href="/JS/jquery.uploadify-v2.1.0/uploadify.css" rel="stylesheet" type="text/css" />
    2  <script type="text/javascript" src="/JS/jquery.uploadify-v2.1.0/swfobject.js"></script>
    3  <script type="text/javascript" src="/JS/jquery.uploadify-v2.1.0/jquery.uploadify.v2.1.0.min.js"></script>

    http://pan.baidu.com/share/link?shareid=415941&uk=1041329344

    js

     1 <script type="text/javascript">
     2             $(document).ready(function () {
     3                 $("#uploadify").uploadify({
     4                     'uploader': '/JS/jquery.uploadify-v2.1.0/uploadify.swf',
     5                     'script': '/UploadHandler.ashx',
     6                     'cancelImg': '/JS/jquery.uploadify-v2.1.0/cancel.png',
     7                     'folder': 'UploadFile',
     8                     'queueID': 'fileQueue',
     9                     'multi': false,
    10                     'fileExt': '*.rar;*.biz',
    11                     'buttonImg': '/App_Themes/UI/image/fa.gif',
    12                     'auto': true,
    13                     'width': '74',
    14                     'height': '13',
    15                     'onComplete': function (event, queueId, fileObj, response, data) {
    16                         $("#beg").find("div").remove();
    17                         var byteSize = Math.round(fileObj.size / 1024 * 100) * .01;
    18                         var suffix = 'KB';
    19                         if (byteSize > 1000) {
    20                             byteSize = Math.round(byteSize * .001 * 100) * .01;
    21                             suffix = 'MB';
    22                         }
    23                         var pic = response.split(",");
    24                         if (pic.length > 1) {
    25                             response = pic[1];
    26                             $("input[name=FilePath]").val(pic[0]);
    27                             $("input[name=FilePic]").val(pic[1]);
    28                         }
    29                         else {
    30                             response = pic[0];
    31                             $("input[name=FilePath]").val(pic[0]);
    32                             $("input[name=FilePic]").val(pic[0]);
    33                         }
    34                         var str = "<div style=\"float: left; margin-right: 10px;\"><img src=\"" + response + "\" width=\"50px;\" height=\"50px;\"/></div><div style=\"line-height:26px;\">" + fileObj.name + "<br />" + byteSize.toFixed(2) + "" + suffix + "</div>";
    35                         $("#beg").append(str);
    36                         $("input[name=FileName]").val(fileObj.name);
    37                         $("input[name=FileSize]").val(byteSize.toFixed(2) + suffix);
    38                     }
    39                 });
    40             });
    41         </script>

    调用(span标签是一个图)

    1 <input type="hidden" name="FileName"/>
    2 <input type="hidden" name="FilePath"/>
    3 <input type="hidden" name="FilePic"/>
    4 <input type="hidden" name="FileSize"/>
    5 <input type="file" name="uploadify" id="uploadify"/> <span class="Gray" style="margin-left: 5px;">请上传格式为【*.biz】或者【*.rar】的附件。</span><a href="" class="blue">无法正常上传?</a>
    6 <div id="fileQueue"></div>
    7 <div id="beg" style="margin-top:10px;"></div>

    效果

  • 相关阅读:
    练习1-6
    c语言while(1)和while(0)
    练习1-3
    每天总结模电--(三)
    每天总结模电——贴片电阻,电容的命名规则(二)
    服务器应用的通用功能
    UML
    算法合集
    python笔记
    笔面试(2019秋招阶段)
  • 原文地址:https://www.cnblogs.com/dany/p/3014483.html
Copyright © 2020-2023  润新知