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;

         }

  • 相关阅读:
    「UVA12293」 Box Game
    「CF803C」 Maximal GCD
    「CF525D」Arthur and Walls
    「CF442C」 Artem and Array
    LeetCode lcci 16.03 交点
    LeetCode 1305 两棵二叉搜索树中的所有元素
    LeetCode 1040 移动石子直到连续 II
    LeetCode 664 奇怪的打印机
    iOS UIPageViewController系统方法崩溃修复
    LeetCode 334 递增的三元子序列
  • 原文地址:https://www.cnblogs.com/zcwry/p/tupian.html
Copyright © 2011-2022 走看看