This documentation is archived and is not being maintained.

HtmlInputFile::Accept Property

Gets or sets a comma-separated list of MIME encodings used to constrain the file types the user can select.

Namespace:  System.Web.UI.HtmlControls
Assembly:  System.Web (in System.Web.dll)

public:
property String^ Accept {
	String^ get ();
	void set (String^ value);
}
<asp:HtmlInputFile Accept="String" />

Property Value

Type: System::String
The comma-separated list of MIME encodings.

Use this property to specify the file type that can be uploaded to the server. For example, to restrict the selection to images, set this property to "image/*".

NoteNote:

Support for this property is browser-dependent. Check your browser to determine whether it supports this property. It is recommended that you use server-side code to ensure that the file is of the expected type.

The following code example demonstrates how to use the Accept property to restrict the user from selecting any file other than an image file. For this example to work properly, you need to create a directory called Temp on your computer's drive C. Because support for the Accept property is browser-dependent, a server-side check is performed to ensure that only images are uploaded. An exception is thrown if the uploaded file can not be read as an Image type.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: