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;

         }

  • 相关阅读:
    pta-L2-032 彩虹瓶 (25 分)
    pat-L2-019 悄悄关注
    谷歌与Airbnb的JS代码规范
    无阻塞加载脚本----性能优化(二)
    web开发者性能优化工具(一)
    threeJS创建mesh,创建平面,设置mesh的平移,旋转、缩放、自传、透明度、拉伸
    攻防世界-web-高手进阶区011-Web_python_template_injection
    攻防世界-web-高手进阶区010-upload1
    攻防世界-web-高手进阶区009-unserialize3
    攻防世界-web-高手进阶区008-PHP2
  • 原文地址:https://www.cnblogs.com/zcwry/p/tupian.html
Copyright © 2011-2022 走看看