FileUpload

V

Victor Rodriguez

Is there a way to filter the file types when you use
<asp:FileUpload></asp:FileUpload>? I would like to limit the user to import
certain types of files.

Thanks,

Victor
 
S

Steven Cheng[MSFT]

Hi Victor,

As for the <asp:FileUpload> control, it is rendered as html <input
type="file" ..../> element. Therefore, if you want to prevent the client
user from uploading certain type of file, you can consider use client-side
script to check the value of the <input type="file"/> element. Use
javascript to check the file extension to see whether the selected file is
of a violate file type. BTW, for security reason, you can only read the
value of <input type="file" /> element in script , but not set it due to
security restriction.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
V

Victor Rodriguez

Great, I'll do that. Another question, can I find out before hand the file
size, before importing?

thanks,

Victor
 
S

Steven Cheng[MSFT]

Thanks for your reply Victor,

For get the file's size, I'm afraid pure script can not do this due to
security restriction also. BTW, if you do need many powerful and complex
control over the file uploading, I think a rich client solution would be
preferred in such scenario. For example, activex control or IE hosted .net
winform control .... And this is quite popular for intranet application
since it is easier to ensure client's webbrowser security setting.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top