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.";
            }
        }
  • 相关阅读:
    python种的builtin函数详解第三篇 C
    python中的buildin函数详解(第一篇) C
    python中的formatter的详细用法 C
    python中的builtin函数详解第二篇 C
    python中函数的默认参数陷阱问题 C
    介绍C++11标准的变长参数模板
    猜数字
    父类和子类
    矩形的面积
    水果类
  • 原文地址:https://www.cnblogs.com/MySpace/p/1599826.html
Copyright © 2011-2022 走看看