IFormFile.FileName Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the file name from the Content-Disposition header.
public:
property System::String ^ FileName { System::String ^ get(); };
public string FileName { get; }
member this.FileName : string
Public ReadOnly Property FileName As String
Property Value
Remarks
Do not use the FileName property of IFormFile other than for display and logging. When displaying or logging, HTML encode the file name. A cyberattacker can provide a malicious filename, including full paths or relative paths.
You can use the following code to remove the path from the file name:
string untrustedFileName = Path.GetFileName(formFile.FileName);