zoukankan      html  css  js  c++  java
  • FileUpload路径

    string xlsPath = this.FileUpload1.PostedFile.FileName;
    string xlsPath = Server.MapPath("~/Excel/客户需求表.xls");

    两者区别:
    前者是物理路径,后者是服务器路径.
     
     
    FileUpload ful = new FileUpload();

            ful.FileName;   //文件件
            ful.PostedFile.ContentLength;//文件大小,单位 B,除以 1024得到 K
            ful.PostedFile.FileName;//完全路径



    protected void Button1_Click(object sender, EventArgs e)
        {
            Boolean fileOK = false;
            String path = Server.MapPath("~/UploadedImages/");
            if (FileUpload1.HasFile)
            {
                String fileExtension =
                    System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
                String[] allowedExtensions =
                    { ".gif", ".png", ".jpeg", ".jpg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions)
                    {
                        fileOK = true;
                    }
                }
            }
            if (fileOK)
            {
                try
                {
                    FileUpload1.PostedFile.SaveAs(path
                        + FileUpload1.FileName);
                    Label1.Text = "File uploaded!";
                }
                catch (Exception ex)
                {
                    Label1.Text = "File could not be uploaded.";
                }
            }
            else
            {
                Label1.Text = "Cannot accept files of this type.";
            }
        }
  • 相关阅读:
    android intent 隐式意图和显示意图(activity跳转)
    Stack栈的三种含义
    gdi+ 高速绘制透明窗体
    Hibernate Criterion
    iOS安全攻防(三):使用Reveal分析他人app
    Android入门第八篇之GridView(九宫图)
    【Android动画】之Tween动画 (渐变、缩放、位移、旋转)
    Ubuntu下deb包的安装方法
    理解class.forName()
    Myeclipse7.5 下载 安装 注冊 注冊码 100%成功
  • 原文地址:https://www.cnblogs.com/MySpace/p/1599826.html
Copyright © 2011-2022 走看看