public JsonResult UpdateImages(int Id, IFormCollection col) { user.ImageId = Id; user.ImageTitle = UrlSeo.ConvertToSeoUrl(col["imageupdatetitle"]); user.ImageWithoutSeoTitle = col["imageupdatetitle"]; user.ImageCategoryFk = Convert.ToInt32(col["imageupdatecategory"]); userimages.SPUpdateImages(user.ImageId, user.ImageTitle, user.ImageWithoutSeoTitle, user.ImageCategoryFk); return(Json((UserImages)user)); }
public async Task <JsonResult> UploadImages(IFormFile imagefile, string imagecategory, string imagetitle) { Random rand = new Random(); int randomnumber = rand.Next(); ExifReader exif = new ExifReader(imagefile.OpenReadStream()); string imgpath = string.Concat(RootFolder.RootFolderWithSubFolderAndSlash, GuidFolderName); string uploadpath = Path.GetFullPath(imgpath); if (!Directory.Exists(uploadpath)) { Directory.CreateDirectory(uploadpath); } string filenames = string.Concat(Convert.ToString(randomnumber), Path.GetExtension(imagefile.FileName.ToLower())); string fullpath = Path.Combine(uploadpath, filenames); string repfilename = Path.Combine(imgpath, filenames); ApplyImageInfos(UrlSeo.ConvertToSeoUrl(imagetitle), imagetitle, imagecategory, repfilename.Substring(9).Replace(@"\", @"/"), GuidFolderName, HttpContext.Session.GetString("realusername"), HttpContext.Session.GetString("realemail"), Convert.ToString(randomnumber), Convert.ToString(0), Convert.ToString(0), Convert.ToString(exif.ExifIso), Convert.ToString(exif.ExifFNumber), Convert.ToString(exif.ExifFocalLength), Convert.ToString(exif.ExifLensModel), Convert.ToString(exif.ExifMeteringMode), Convert.ToString(exif.ExifModel), Convert.ToString(exif.ExifShutterSpeedValue), Convert.ToString(exif.ExifExposureMode), Convert.ToString(exif.ExifExposureProgram), Convert.ToString(exif.ExifExposureTime), Convert.ToString(exif.ExifMake)); using (FileStream filewriter = new FileStream(fullpath, FileMode.Create)) { await imagefile.CopyToAsync(filewriter); filewriter.Close(); filewriter.Dispose(); } return(Json((UserImages)userimage)); }