ios和安卓给后台上传图片代码

来源:互联网 发布:mac解压不了zip 编辑:程序博客网 时间:2024/05/01 21:07

前提是用form表单提交下面是实现代码仅供参考。

   public void AddImg()
        {
            HttpFileCollection files = Request.Files;
            HttpPostedFile file = files["pic"];
            System.Drawing.Image imgPic;
            imgPic = System.Drawing.Image.FromStream(file.InputStream);
            string src = DateTime.Now.ToString("yyyyMMddhhmmss") + ".png";
            string path2 = Server.MapPath("~/Image/" + src);
            imgPic.Save(path2, System.Drawing.Imaging.ImageFormat.Png);
            imgPic.Dispose();
            string res = "/Image/" + src;
         
            Response.Write(res);
          
        }
原创粉丝点击