Click or drag to resize

파일 포맷 검사

FormatDetector 오브젝트의 GuessFormat 메서드를 사용하면 서버에 저장되어 있는 파일에 대해 어떠한 파일 형식을 갖고 있는지 쉽게 확인할 수 있습니다.

검사 방법

파일 형식을 검사하기 위해서는 우선 FormatDetector 오브젝트를 생성해야 합니다. 오브젝트 이름은 TABSUpload4.FormatDetector로 Server.CreateObject()를 호출해 생성합니다.

GuessFormat 메서드에 검사할 대상 파일을 입력해 호출하면 파일 형식 정보를 담고 있는 FormatInfo가 반환됩니다.

FormatInfo의 Name과 Description에는 분석한 파일 포맷의 이름과 설명이 반환됩니다.

분석하지 못할 경우 Name에 unknown이 반환됩니다.

ASP
Dim FormatDetector, Format

Set FormatDetector = Server.CreateObject("TABSUpload4.FormatDetector")
Set Format = FormatDetector.GuessFormat("C:\Temp\document.xls")

Response.Write "파일 포맷:" & Format.Name & "<br>"
Response.Write "파일 포맷 설명:" & Format.Description & "<br>"
Response.Write "파일 포맷 MIME 형식:" & Format.MimeType & "<br>"