i am new to ASP.net COre and i would like to upload a file ( an image) and store it in a secific Folder. ihave been following this tuto (File uploads in ASP.NET Core) but i
Just used the accepted answer from @Saineshwar, but did a little bit refactoring as one extension method to make it easy to use IFromFile
public static string MakeFileUniqueName(this IFormFile formFile)
{
if (formFile.Length > 0)
{
string fileName =
ContentDispositionHeaderValue.Parse(formFile.ContentDisposition).FileName.Trim('"');
// concatinating FileName + FileExtension
return Guid.NewGuid() + Path.GetExtension(fileName);
}
return string.Empty;
}