Share via


IFormFile.FileName Property

Definition

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);

Applies to