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.";
            }
        }
  • 相关阅读:
    2018杭电多校第六场1009(DFS,思维)
    Atcoder Regular Contest 085F(动态规划,线段树)
    IOS各类优化方案集锦
    iOS网络加载图片缓存策略之ASIDownloadCache缓存优化
    oc
    OC 内存管理机制总结
    ARC小知识
    oc常见误区
    常用第三方(分享,支付,二维码,语音,推送)
    UIKit,Core Data , Core Graphics, Core Animation,和OpenGLES框架
  • 原文地址:https://www.cnblogs.com/MySpace/p/1599826.html
Copyright © 2011-2022 走看看