as i am trying to upload a File, and i am trying to check for their extension, as i know it is not a good practice, so this is the code which i am doing this. it works fine, but as i am facing issue in Apple Mac Users, they are not unable to upload pdf files.
if (upload1.HasFile)
{
Finfo = new FileInfo(upload1.PostedFile.FileName);
if (Finfo.Extension.ToLower() == ".docx" || Finfo.Extension.ToLower() == ".doc" || Finfo.Extension.ToLower() == ".xls" ||
Finfo.Extension.ToLower() == ".xlsx" || Finfo.Extension.ToLower() == ".pdf" || Finfo.Extension.ToLower() == ".jpg" ||
Finfo.Extension.ToLower() == ".png" || Finfo.Extension.ToLower() == ".gif" || Finfo.Extension.ToLower() == ".txt" ||
Finfo.Extension.ToLower() == ".mp4" || Finfo.Extension.ToLower() == "ppt" || Finfo.Extension.ToLower() == ".bmp" ||
Finfo.Extension.ToLower() == ".swf" || Finfo.Extension.ToLower() == ".rm" || Finfo.Extension.ToLower() == ".pptx")
{
// Accept File
}
}
now what i thought i will use this code, so that it will solve the problem
if (
upload1.PostedFile.ContentType == "text/rtf" ||
upload1.PostedFile.ContentType == "application/doc" ||
upload1.PostedFile.ContentType == "appl/text" ||
upload1.PostedFile.ContentType == "application/vnd.msword" ||
upload1.PostedFile.ContentType == "application/vnd.ms-word" ||
upload1.PostedFile.ContentType == "application/winword" ||
upload1.PostedFile.ContentType == "application/word" ||
upload1.PostedFile.ContentType == "application/msword" ||
upload1.PostedFile.ContentType == "application/x-msw6" ||
upload1.PostedFile.ContentType == "application/x-msword" ||
upload1.PostedFile.ContentType == "application/pdf" ||
FileUpload1.PostedFile.ContentType == "application/x-pdf" ||
upload1.PostedFile.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
upload1.PostedFile.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.template"
)
is it good way to Accept Files from users. I need to allow All Files Except EXE,DMG, DLL,CS, SQL, BAT, . how do i ensure that it will work on all operating systems.
- Apple user may use OpenOffice, or some other softwares to upload. so we need to allow this type of file also
can anybody tell me how to handle this situations