How to allow only certain file types for upload?

S

Showjumper

I have an upload server control and i want to set it up in such a way that
allowed file types (extensions) can be specified in a property in the
property window. The different files types just separated by a comma for
instance. Right allowed file types are hardcoded into the array list and if
i need to add an addtional one i have to recompile each time. How can i get
the comma delimited string in the allowed files property and add each
individual file type to the array list? I have tried various things but
havent been able to get it yet.

Thanks
Ashok
 
C

Chris Jackson

The way that you handle file uploads in DHTML is to use the <input
type="file> element, which doesn't have the same rich properties that you
would find in a Windows application for setting this property. (At least, I
am not aware of it if there are, and I just glanced at the docs to verify
that I wasn't missing anything obvious.) So, you have a couple of options.
First, you could implement some client-side event handling that would
retrieve the value of the control (which returns the file name) and check
the extension. Then, you only submit if you pass validation. Second, you
could implement an embedded WinForms or ActiveX control that gives you
richer functionality, at the expense of requiring people to trust your
controls to do what they say they do. Third, you could get lucky and
somebody could post back that I have, indeed, missed the property setting
that allows this. :)
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top