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;

    }

  • 相关阅读:
    静态检查lua语法工具luacheck
    centos7系列:
    git submodule 教程
    CENTOS 7 安装redis
    python基本语法:
    彻底理解lib和dll
    C++语言的设计与演化(空白):
    《Effective C++》 目录:
    C++进阶书籍(转)
    学习的心态(转)
  • 原文地址:https://www.cnblogs.com/wggWeb/p/2327531.html
Copyright © 2011-2022 走看看