• uploadify ASP.net 使用笔记


    <script type="text/javascript" src="jquery.uploadify.min.js"></script

    <link rel="Stylesheet" href="uploadify.css" type="text/css" />
    <script type="text/javascript">
            $(document).ready(function () {
                $('#uploadify').uploadify({
                    'swf': 'uploadify.swf',
                    'buttonText': 'Loading',
                    'uploader': 'Uploadhandler.ashx',
                    'queueID': 'fileQueue',
                    'queueSizeLimit': 10,
                    'auto': false,
                    'multi': false,
                    'removeCompleted': true,
                    'fileSizeLimit': '100MB',
                    'fileTypeDesc': 'Excel文件',
                    'fileTypeExts': '*.xls',
                    'onUploadSuccess': function (file, data, response) {
                        layer.closeAll();
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-rim', //加上边框
                            area: ['520px', '340px'], //宽高
                            content: '<div>File Name:' + file.name + data + '</div>'
                        });
                    },
                    'onUploadError': function (event, queueId, fileObj, errorObj) {
                        layer.closeAll();
                    },
                    'onUploadStart': function (file) {
                        $("#uploadify").uploadify("settings", "formData", { 'ddlregion': $('#ddlRegionSearch').val() });  //动态参数
                    } 
                });
    
                $('#supload').click(function supload() {
                    $('#uploadify').uploadify('upload', '*');
                });
            });
        </script>
      <div>
        <input type="file" name="uploadify" id="uploadify" /><button id="supload" class="btn">开始上传</button>
      </div>
      <div id="fileQueue"></div>
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Charset = "utf-8";
    
        HttpPostedFile file = context.Request.Files["Filedata"];
        string uploadPath = context.Request.MapPath("/Upload/Files/");
    
        try
        {
        if (file != null)
        {
            string fileName = uploadPath + file.FileName;
            if (!Directory.Exists(uploadPath))
            {
            Directory.CreateDirectory(uploadPath);
            }
    
            //将文件上传至服务器
            file.SaveAs(fileName);
            context.Response.Write("<br>The import is complete!");
        }
        else
        {
            context.Response.Write("<br>File loading failure!");
            return;
        }
        }
        catch (Exception ex)
        {
        context.Response.Write("<br>Exception: " + ex.Message);
        }
    }
  • 相关阅读:
    CentOS7安装(三)- 配置阿里云yum源
    OSQA的配置
    MySQL学习 (三) Limit-Distinct-Union
    MySQL学习(二)-字段类型及约束
    MySQL学习(一)-基本知识
    Python闭包
    软件测试面试常考点
    人生感悟
    常用的Linux命令
    细说php一些常见的知识点
  • 原文地址:https://www.cnblogs.com/fanxingthink/p/5845596.html
Copyright © 2020-2023  润新知