how do i Filter extensions in FileUpload Control
-
Hi Friends, i m using FileUpload Control in my page now i want, user not able to upload .exe file for that i need to specify filter fo extensions how do i Filter extensions??? thanks
Amit Metkar 3i-infotech, Mumbai.
-
Hi Friends, i m using FileUpload Control in my page now i want, user not able to upload .exe file for that i need to specify filter fo extensions how do i Filter extensions??? thanks
Amit Metkar 3i-infotech, Mumbai.
No. AFAIK, it's not possible to do that with File Upload control. maybe. you may look around flash or ActiveX control.. I'm sure that HTML file control doesn't have that feature. So, you will have to check the extension at code-behind.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
Hi Friends, i m using FileUpload Control in my page now i want, user not able to upload .exe file for that i need to specify filter fo extensions how do i Filter extensions??? thanks
Amit Metkar 3i-infotech, Mumbai.
Amit.Amit.Amit..... wrote:
now i want, user not able to upload .exe file for that i need to specify filter fo extensions
Specifying filter is not possible in file upload control. But you can check the file extension like this and alert user regarding that
if (File1.PostedFile.FileName.EndsWith(".exe"))
{
//Display message
}
else
//Upload
-
Hi Friends, i m using FileUpload Control in my page now i want, user not able to upload .exe file for that i need to specify filter fo extensions how do i Filter extensions??? thanks
Amit Metkar 3i-infotech, Mumbai.
Use javascript for the validations since u cant filter the HtmlInputFile control. Ask if u want the code. u have 2 do it in the onchange method.
-
Hi Friends, i m using FileUpload Control in my page now i want, user not able to upload .exe file for that i need to specify filter fo extensions how do i Filter extensions??? thanks
Amit Metkar 3i-infotech, Mumbai.
Use javascript for the validations since u cant filter the HtmlInputFile control. Ask if u want the code u have 2 do it in the onchange method.
-
Use javascript for the validations since u cant filter the HtmlInputFile control. Ask if u want the code. u have 2 do it in the onchange method.
javascript cannot interact with the input control, or the file system, AFAIK.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi Friends, i m using FileUpload Control in my page now i want, user not able to upload .exe file for that i need to specify filter fo extensions how do i Filter extensions??? thanks
Amit Metkar 3i-infotech, Mumbai.
you should use this code: private bool IsAccept(string fileName) { bool ok = false; string ext = System.IO.Path.GetExtension(fileName); if (ext == ".jpe" || ext == ".jpeg" || ext == ".pjpeg" || ext == ".gif" || ext == ".jpg" || ext == ".bmp" || ext == ".png" || ext == ".x-png") { ok = true; } return ok; } Hope that help you! vtkiet05
-
javascript cannot interact with the input control, or the file system, AFAIK.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
I guess the code vtkiet05 shows us is Server-side code. not Javascript. I believe that that code is not interacting with File System. It's just trying to get the extension of file by using System.IO.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
Hi Friends, i m using FileUpload Control in my page now i want, user not able to upload .exe file for that i need to specify filter fo extensions how do i Filter extensions??? thanks
Amit Metkar 3i-infotech, Mumbai.
Thank U Friends I got the Solution.... Thanx :):):):):)
Amit Metkar 3i-infotech, Mumbai.