ASP.NET File Upload Progress - Allowed File Extensions and Sizes

This example demonstrates how to set available extensions and maximum size for uploading files.
Here can be uploaded files with extension gif (maximum size 10000 bytes) and files with extension txt of any size.

On submit fileinputsthat contain files with not allowed extensions are cleared and no submit occurs. Client-side function is called after this clearing if OnClientFileCleared property of control is set.
Files with size exceeding maximum arerejectedfrom HTTP request and server-side does not receive them. Client-side function is called after every such reject if OnClientFileRejected property of control is set.

Example code

<%@ Register TagPrefix="fup" Namespace="OboutInc.FileUpload" Assembly="obout_FileUpload" %>
<script type="text/JavaScript">
function Rejected(fileName, size, maxSize){
  var addMessage = (maxSize >= 0)?("exceeds "+maxSize+" bytes"):("-- session lost");
  alert("File "+fileName+" is rejected \nIts size ("+size+" bytes) "+addMessage);
function ClearedFiles(fileNames){
  alert("Cleared files with bad extensions:\n\n"+fileNames);
<input type=file name="myFile1"><br/>
<input type=file name="myFile2"><br/>
<input type=file name="myFile3"><br/>
<input type=submit value="submit" name="mySubmit"><br/>

<fup:FileUploadProgress runat="server" ShowUploadedFiles="true"
     OnClientProgressStopped="function(){alert('My custom OnClientProgressStopped event');}"
     OnClientFileRejected="Rejected" OnClientFileCleared="ClearedFiles"
        <fup:Format Ext="gif" MaxByteSize="10000" />
        <fup:Format Ext="txt" />

See also Server side properties, OnClientFileCleared function, OnClientFileRejected function pages.