Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Post(FlyerDetails FlyerDetails)
- {
- var httpRequest = HttpContext.Current.Request;
- if (httpRequest.Files.Count > 0)
- {
- foreach (string file in httpRequest.Files)
- {
- var filePath = HttpContext.Current.Server.MapPath("~/Flyers/" + httpRequest.Files[file].FileName);
- Bitmap bmp = new Bitmap(httpRequest.Files[file].InputStream);
- Graphics g = Graphics.FromImage(bmp);
- g.SmoothingMode = SmoothingMode.AntiAlias;
- g.InterpolationMode = InterpolationMode.HighQualityBicubic;
- g.PixelOffsetMode = PixelOffsetMode.HighQuality;
- g.DrawString(FlyerDetails.Message, new Font(FlyerDetails.FontColor, FlyerDetails.FontSize), Brushes.DarkRed, new PointF(0, 0));
- g.Flush();
- bmp.Save(filePath);
- }
- }
- }
- public async Task<HttpResponseMessage> Post()
- {
- var streamProvider = new MultipartFormDataStreamProvider(HttpContext.Current.Server.MapPath("~/Flyers/"));
- await Request.Content.ReadAsMultipartAsync(streamProvider);
- var response = Request.CreateResponse(HttpStatusCode.Created);
- var filePath = "";// file path
- if (System.IO.File.Exists(filePath))
- {
- string extension = Path.GetExtension(filePath);
- Bitmap bmp = new Bitmap(filePath);
- Graphics g = Graphics.FromImage(bmp);
- g.SmoothingMode = SmoothingMode.AntiAlias;
- g.InterpolationMode = InterpolationMode.HighQualityBicubic;
- g.PixelOffsetMode = PixelOffsetMode.HighQuality;
- Color brushColor = System.Drawing.ColorTranslator.FromHtml(streamProvider.FormData["FontColorCode"]);
- g.DrawString(streamProvider.FormData["FontFamily"], new Font(brushColor.Name, Convert.ToInt32(streamProvider.FormData["FontSize"])), new SolidBrush(brushColor), new PointF(0, 0));
- g.Flush();
- bmp.Save(HttpContext.Current.Server.MapPath("~/" + Guid.NewGuid() + extension));
- response.Headers.Location = new Uri(new Uri(HttpContext.Current.Request.Url.AbsoluteUri).GetLeftPart(UriPartial.Authority) + "/Flyers/" + Guid.NewGuid() + extension);
- }
- return response;
- }
- string value = HttpContext.Current.Request.Params.Get("key");
Add Comment
Please, Sign In to add comment