zoukankan      html  css  js  c++  java
  • 上传进度基础

    HttpFileCollection hfc = Request.Files;
            if (hfc.Count > 0)
            {
                FileStream fs;
                Stream _stream;
                int btLen = 10000;
                byte[] _byte = new byte[btLen];
                int len, ysc = 0;
                string _root = Server.MapPath("~");
                HttpPostedFile hpf;
                foreach (string str in hfc)
                {
                    hpf = hfc[str];
                    if (hpf.ContentLength > 0)
                    {
                        fs = new FileStream(_root + "/" + hpf.FileName, FileMode.Create);
                        _stream = hpf.InputStream;
                        len = _stream.Read(_byte, 0, btLen);
                        while (len > 0)
                        {
                            ysc += len;
                            fs.Write(_byte, 0, len);
                            len = _stream.Read(_byte, 0, btLen);
                        }
                        _byte = null;
                        hpf = null;
                        _stream.Close();
                        _stream = null;
                        fs.Close();
                        fs = null;
                    }
                }
            }
    //实时获取 根据ysc和hpf.ContentLength计算上传进度
  • 相关阅读:
    DHCP脚本
    7.31
    7.30
    7.26
    7.24
    VLAN与三层交换机
    静态路由配置
    7.17
    四次挥手
    TCP三次握手,四次挥手
  • 原文地址:https://www.cnblogs.com/daixingqing/p/3347110.html
Copyright © 2011-2022 走看看