<asp:FileUpload ID="FileUpload1" runat="server" accept="image/*" />
HttpFileCollection upFiles = Request.Files; if (upFiles.Count > 0 && upFiles.Count < 2) { string wenjianjia = "a_" + DateTime.Now.ToString("yyyy-MM-dd"); string savePath = "/plugins/dangxingtijian/PC/face/img/" + wenjianjia; string savePaths = MapPath(savePath); if (!Directory.Exists(savePaths)) { Directory.CreateDirectory(savePaths); } for (int i = 0; i < upFiles.Count; i++) { string url_a = "a" + DateTime.Now.Ticks.ToString() + i; string url_f = "f" + DateTime.Now.Ticks.ToString() + i; string extendName = string.Empty; HttpPostedFile PostedFile = upFiles[i]; if (PostedFile.ContentLength > 0) { extendName = Path.GetExtension(PostedFile.FileName.ToLower()).Replace(".", ""); //保存 原始图 url_a = "/" + url_a + "." + extendName; url_f = "/" + url_f + "." + extendName; string url_as = savePaths + url_a; string url_fs = savePaths + url_f; //苹果手机 图片角度 调整 string url = savePaths + url_f; PostedFile.SaveAs(url); RemoveRotateFlips(url, url_as); File.Delete(url); //缩略图 MakeThumbnail(url_as, url_fs, 300, 400, "HW"); File.Delete(url_as); //显示 图片 img_face.ImageUrl = savePath + url_f; } } return true; } else { return false; } } #endregion