^^ 안녕하세요.
보통의 자료실에 보면,,, text 화일이나 그림,, 또는 Office 관련 화일들은 브라우져에서 자동으로 띄워 버립니다. 그럼, 만약 text,그림,Office 화일까지도 다운을 받고 싶다면 어떻게 하면 될까여? ContentType 과 html 헤더의 조작으로 가능합니다. IIS에서 MIME Type을 설정할수도, 바꿀수도 있다는 사실은 알고 계시리라 믿습니다.
일단 다운 버튼을 누르면,,, down.asp 화일로 보냅니다. down.asp?fname=a.txt 이런식으로 보내면 되겠지요? 데이타 베이스에 화일이름이 저장되어 있을 겁니다. 위의 소스에서는 ADO 2.5 에 포함되어 있는 Stream 객체를 이용하여 다운 받는 부분을 해결했습니다. Stream 객체에 포함되어 있는 LoadFromFile 메소드와 ReadText 메소드를 이용해서 화일을 읽어 왔습니다. Response.BinaryWrite 를 이용해 클라이 언트에 저장하게 됩니다. ^^ filename="&fname 은 저장할 화일의 이름이랍니다. 생각보단 너무 간단하지요? 도움이 되셨길 바랍니다. 아래는 또다른 방법입니다.(SiteGalaxyUpload) Response.ContentType ="application/x-gzip" fname=Request("fname") Response.AddHeader "Content-Disposition", "attachment;filename="&fname str_dir="c:\temp\" set fso = server.CreateObject ("SiteGalaxyUpload.filesystemobject") set file = fso.OpenBinaryFile (str_dir&fname,1,false) Response.BinaryWrite file.readall Response.End ContentType 종류 Response.ContentType = "application/x-msdownload" Response.ContentType = "application/x-gzip" Response.ContentType = "application/unknown" Response.ContentType = "application/vnd.ms-excel"
|
|||||||||||