zoukankan      html  css  js  c++  java
  • FileUpload 控件上传图片和文件

    2012年1月19日

    //获取文件名称

    string fileName=FileUpload1.FileName;

    //获取文件的大小

    string fileSize=FileUpload1.PostedFile.ContentLength.ToString();

    //获取文件的类型

    string flieType=FileUpload1.PostedFile.ContentType;

    //获取文件的后缀名

    string fileNameType=fileName.Substring(fileName.LastIndexOf("."+1);

    //是图片的保存路径;img为服务器目录上的文件夹

    string ImgSavePath=Server.MapPath(Request.ApplicationPath+"/img")+"\\"+fileName;

    //是文件的保存路径;file为服务器上目录上的文件夹

    string FileSavePath=Server.MapPath(Request.applicationPath+"/file")+"\\"+fileName;

    //在项目上的路径

    string projectPath=Request.ApplicationPath+"img/"+fileName;

    if(fileNameType=="jpg"||fileNameType=="bmp"||fileNameType=="gif"){

         FileUpload1.SaveAs(ImgSavePath);

         Image1.ImageUri=projectPth;

    }

    else

    {

       FileUpload1.SaveAs(FileSavePath);

       Image.Visible=false;

    }

  • 相关阅读:
    sklearn
    Scrapy
    正则表达式re
    BeautifulSoup
    requests
    Python网络爬虫与信息提取
    Matplotlib
    Pandas
    NumPy
    制约大数据处理能力的几个问题
  • 原文地址:https://www.cnblogs.com/wggWeb/p/2327531.html
Copyright © 2011-2022 走看看