Gagri Global IT services is having a team of executives who have good experience in developing applications on various platforms like SharePoint 2013/2010, Silverlight, net Framework 4.5 and Mobile tools.
Posted on December 14, 2023 by Amruthavalli
[System.Web.Http.AcceptVerbs("GET", "POST")]
[System.Web.Http.HttpPost]
public string UploadEmergencyTypeImage()
{
try
{
var filepath = "";
if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
{
var baseFolder = "Content\\PDFS\\";
string folderPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, baseFolder);
if (!Directory.Exists(folderPath))
{
System.IO.Directory.CreateDirectory(folderPath);
}
var httpPostedFile = System.Web.HttpContext.Current.Request.Files["PostedFile"];
if (httpPostedFile != null)
{
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(httpPostedFile.FileName);
var fileExtension = Path.GetExtension(httpPostedFile.FileName);
var dateTimeNow = DateTime.Now.ToString("yyyy-MM-dd-HH-mm");
var fileNameWithDateTime = $"{fileNameWithoutExtension}{dateTimeNow}{fileExtension}";
var fileSavePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/PDFS/"), fileNameWithDateTime);
httpPostedFile.SaveAs(fileSavePath);
filepath = "/Content/PDFS/" + fileNameWithDateTime;
}
}
return filepath;
}
catch (Exception ex)
{
exp.ExceptionHandler(ex);
return "";
}
}
#endregion
All design and content Copyright © 2012-2018 Gagri Global IT Services Pvt.Ltd. All rights reserved