How to filter file types when using the HTMLInputFile control...

A

Asela Gunawardena

On my Web Servers, I don't want to allow visitors to upload executables.
There are many types of files that i want to ignore (for instance: exe,dll,
bat, cmd .etc). I have an ASPX page with an HTMLInputFile control which
uploads the files. Is it possible to set a filter when the user clicks the
Browse button so that the
file selection dialog only displays valid formats specified.

thankx in advance

Asela Gunawardena.
 
D

dbottjer

You could maintain a list of acceptable file types in a collection and then
loop through this collection checking it against the file being uploaded.
You would need to use some VB.NET code like this:

fileExtension = Mid(fileName, InStrRev(fileName, ".") + 1)

To figure out the file extension of the uploaded file.
 
A

Asela Gunawardena

thankx, but this of course i do check. what i would like to know is whether
there is a way of restricting the user select the unnessary formats when the
file dialog appears; making only the relavant types appear.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top