Quick Links
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 file
inputs
that 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 are
rejected
from 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);
}
</
script
>
...
<
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"
>
<
AllowedFileFormats
>
<
fup:Format
Ext
="gif"
MaxByteSize
="10000"
/
>
<
fup:Format
Ext
="txt"
/
>
<
/
AllowedFileFormats
>
<
/
fup:FileUploadProgress
>
See also
Server side properties
,
OnClientFileCleared function
,
OnClientFileRejected function
pages.
Uploaded 
% (
) Total
Uploaded
files
file
from
Uploading file
Last uploaded file
:
Elapsed time:
Estimated time:
Speed:
(Session lost)
rejected
uploaded
obout.com
obout.com Home
File Upload Progress Home
File Upload Progress Home
Download
Site Map
Examples
- 17
Default settings
Show uploaded files names
Client-side events handling
Another style
Localization
Custom time format
Preserve space
Allowed file extensions and sizes
StatusPanel
control use
Add/delete file inputs
Cancel data transmitting
Customize
- 2
Custom style file
Custom localization file
Configuration
- 4
obout_FileUpload DLL
Web Configuration
- 3
UploadProgressModule
UploadProgressHandler
Optional settings
Knowledge Base
- 1
Knowledge Base
Documentation
- 5
Server side properties
Client side interface
- 3
OnClientProgressRefreshed
OnClientFileCleared
OnClientFileRejected
Upload large files
ChangeLog
ASP.NET 2.0-4.0
AJAX Page
Calendar
Color Picker
Date Picker
File Upload Progress
Flyout
Grid
HTML Editor
Image Zoom
Listbox
Multilevel Listbox
Show
Spell Checker
Splitter
Super Form
Tab Strip
TreeView
Tree_DB
Window
Menu
Context Menu
Easy Menu
Slide Menu
Text Menu
Combobox
Combobox
AJAX Autosuggest
Multilevel Combobox
State Selector
Interface Controls
Button
Checkbox
Dropdown List
Multiline Textbox
Radio Button
Textbox
ASP.NET 3.5-4.0
Color Picker
File Upload
HTML Editor
Spell Checker
TreeView
ASP.NET MVC
Combobox
HTML Editor
Interface Controls
Listbox
Multilevel Combobox
Multilevel Listbox
State Selector
Download
Suite for ASP.NET
Customer log-in
Support
Knowledge base
Contact support
Install FAQ
Mailing list
Compare versions
Purchase
Purchase page
Contact Sales
License info
Terms of use
Company
Testimonials
Clients
About us
Contact us