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

    /// <summary>

        /// 这是图件的上传

        /// </summary>

        /// 创建时间:2012/06/27

        public string tujian()

        {

            string path = "";

            if (FileUpload1.HasFile)

            {

                if (FileUpload1.PostedFile.ContentLength > 1000 * 1000)

                {

                    Response.Write("过大");

                }

                else

                {

                  if (FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(".")).ToLower() != ".jpg")

                    {

                        ClientScript.RegisterStartupScript(this.GetType(), "a1", "<script>alert('格式不正确')</script>");

                    }

                    else

                    {

                        string strFileNewName = DateTime.Now.ToString("yyyyMMddhhmmss") ;

                        // FileUpload1.SaveAs(@"E:\"+FileUpload1.FileName);

                        FileUpload1.SaveAs(Server.MapPath("FileExcel") + "\\" + strFileNewName+FileUpload1.FileName);

                        //获取刚刚上传文件路径

                        path =  strFileNewName + FileUpload1.FileName ;

                        //ClientScript.RegisterStartupScript(GetType(), "xxx", "<script>alert('上传成功');</script>");

                        string s = string.Format("<script>alert('{0}')</script>", "上传成功!");

                        ClientScript.RegisterStartupScript(this.GetType(), "xxx", s);

                     }

               }

            }

            return path;

         }

  • 相关阅读:
    禅道
    centos7 安装redis 出现cc: command not found错误解决
    Linux 安装 redis
    vuex store modules
    vuex store 改造
    vuex store
    Vue axios
    Vue keep-alive
    vue 路由守卫
    vue-router 参数传递
  • 原文地址:https://www.cnblogs.com/zcwry/p/tupian.html
Copyright © 2011-2022 走看看