日期:2014-05-17 浏览次数:20452 次
HttpPostedFile oFile = HttpContext.Current.Request.Files[HttpContext.Current.Request.Files.AllKeys[0]]; oFile.SaveAs(System.Web.HttpContext.Current.Server.MapPath("~") + sFileName);//上传图片
HttpPostedFile oFile = HttpContext.Current.Request.Files[HttpContext.Current.Request.Files.AllKeys[0]]; using (FileStream fs = new FileStream(sFilePath, FileMode.Create, FileAccess.Write, FileShare.None)) { const int bufferLen = 4096; byte[] buffer = new byte[bufferLen]; int count = 0; while ((count = oFile.InputStream.Read(buffer, 0, bufferLen)) > 0) { fs.Write(buffer, 0, count); } fs.Close(); oFile.InputStream.Close(); }