예제 #1
0
        public static bool IsSecureUploadPhoto(HttpPostedFile oFile)
        {
            bool   flag = false;
            string a    = Path.GetExtension(oFile.FileName).ToLower();

            string[] array = new string[]
            {
                ".gif",
                ".png",
                ".jpeg",
                ".jpg",
                ".bmp"
            };
            for (int i = 0; i < array.Length; i++)
            {
                if (a == array[i])
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                return(true);
            }
            FileExtension[] fileEx = new FileExtension[]
            {
                FileExtension.BMP,
                FileExtension.GIF,
                FileExtension.JPG,
                FileExtension.PNG
            };
            return(FileValidation.IsAllowedExtension(oFile, fileEx));
        }
예제 #2
0
        public static bool IsSecureUploadPhoto(HttpPostedFile oFile)
        {
            bool   flag  = false;
            string lower = Path.GetExtension(oFile.FileName).ToLower();

            string[] strArray = new string[5]
            {
                ".gif",
                ".png",
                ".jpeg",
                ".jpg",
                ".bmp"
            };
            foreach (string str in strArray)
            {
                if (lower == str)
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                return(true);
            }
            FileExtension[] fileEx = new FileExtension[4]
            {
                FileExtension.BMP,
                FileExtension.GIF,
                FileExtension.JPG,
                FileExtension.PNG
            };
            return(FileValidation.IsAllowedExtension(oFile, fileEx));
        }