Jen, much clearer now. You cannot control through server side code, you can
check what files are being uploaded and limit option to disallow this with
an error message showing wrong file name. But this is not what you want.
What your saying is you want to filter out file types for you input file
element. This is possible by using the accept attribute for your input file
element and supplying it a list of files you want to accept.
Sample :
<input type="file" name="uploaded_file" accept="image/png, image/gif" />
Examples of content types include "text/html", "image/png", "image/gif",
"video/mpeg", "audio/basic", "text/tcl", "text/javascript", and
"text/vbscript". For the current list of registered Multipurpose Internet
Mail Extensions (MIME) types, see
http://www.w3.org/TR/1998/REC-html40-19980424/references.html#ref-MIMETYPES
On a side note : Always use the enctype of "multi-part/form-data" on the
form, otherwise the files will not upload correctly
Jen said:
Hi Alessandro,
Thank you for your help. But I am a newbie in aspnet and C#. Pardon me, if I sound silly.
First of all, my development environment is asp.net for web. The codes
you provide me with seems to be meant for window base (I really don't know
how to apply it). Therefore, I didn't manage to get it working. I am using
"file field" with the default "browse" button.