public ActionResult Upload(string qqfile) { try { var stream = Request.InputStream; if (Request.Files.Count > 0) { HttpPostedFileBase postedFile = Request.Files[0]; stream = postedFile.InputStream; } string fileUrl = _logoManager.GetPath("img" + DateTime.Now.Ticks + ".jpg"); var image = new Bitmap(stream); image = image.Resize(150, 1024); image.SaveJpeg(Server.MapPath(fileUrl), 90); return Json(new { imageUrl = fileUrl }); } catch (Exception ex) { return Json(new { imageUrl = _logoManager.GetPath(String.Empty) }); } }
/// <summary> /// Creates a image with the date on it. /// </summary> private static void GenerateDateImage() { string strDisplay = DateTime.Now.ToString(Properties.Settings.Default.DateFormat); using (Bitmap objBmpImage = new Bitmap(1024, 768)) { Font objFont = new Font(Properties.Settings.Default.DateFont, Properties.Settings.Default.DateSize, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); using (Graphics objGraphics = Graphics.FromImage(objBmpImage)) { objGraphics.Clear(Color.Black); objGraphics.SmoothingMode = SmoothingMode.AntiAlias; objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias; objGraphics.DrawString(strDisplay, objFont, new SolidBrush(Properties.Settings.Default.DateColor), Properties.Settings.Default.DateLeftPadding, Properties.Settings.Default.DateTopPadding); objGraphics.Flush(); //objBmpImage.Save(@"\\HOME\picturebox\test.jpg"); objBmpImage.SaveJpeg(Properties.Settings.Default.ImageDestinationPath + "date.jpg", 100L); } } }