HttpPostedFile file = FileUpload1.PostedFile; byte[] document = new byte[file.ContentLength]; file.InputStream.Read(document, 0, file.ContentLength); System.UInt32 mimetype; FindMimeFromData(0, null, document, 256, null, 0, out mimetype, 0); System.IntPtr mimeTypePtr = new IntPtr(mimetype); string mime = Marshal.PtrToStringUni(mimeTypePtr); Marshal.FreeCoTaskMem(mimeTypePtr); if (mime == "application/pdf") { // upload the File because file is valid // and checking other file type Response.Write("This is Valid File"); } else { // file is Invalid Response.Write("This is Invalid File"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)