zoukankan      html  css  js  c++  java
  • asp.net上传图片

    protected void BtnOk_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.FileName == "")
            {
                this.lblMessage.Text = "<font color=#FF0000>请选择上传的图片!</font>";
                this.FileUpload1.Focus();
                return;
            }
            string filePath = this.FileUpload1.FileName;
    string fileName = filePath.Substring(filePath.LastIndexOf("\\")+1);
            string fileType = filePath.Substring(filePath.LastIndexOf(".")+1);
            string filePic = Server.MapPath("~/images/" + fileName);
            string[] strArr = new string[] { "gif", "jpg", "bmp" };
            for (int i = 0; i < strArr.Length; i++)
            {
                if (fileType.ToLower() == strArr[i])
                {
                    this.FileUpload1.PostedFile.SaveAs(filePic);
                    this.lblMessage.Text = "上传图片成功!";
                    return;
                }
            }
            this.lblMessage.Text = "您上传的图片格式不正确\n,请上传jpg,gif,bmp格式的图片.";
        }

  • 相关阅读:
    zepto.js介绍
    box-sizing属性
    响应式网页高度自适应原理
    固定-比例-固定
    常用的js正则验证
    mysql之连接查询(多表查询)
    数据约束
    mysql表数据的增删改查
    mysql学习之数据库管理与表管理
    滑动选项卡的制作
  • 原文地址:https://www.cnblogs.com/dogxuefeng/p/2661669.html
Copyright © 2011-2022 走看看