[Asp] WebService 로 받아 XML로 리턴하기 예제

asp download file

Response.BinaryWrite Office 2007 docs corrupted

<% file_name = REQUEST("FILE_NAME") ‘다운받을 파일명 strFilePath ="D:\WebSite\DCS\" & file_name ‘경로 URL = strFilePath Dim fso, msg Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists(URL)) Then strName2= Mid(file_name,InstrRev(file_name, ".")+1) strName1 = UCase(trim(strName2)) if strName1 = "EXE" or strName1 ="exe" then URL = "../DCS/" & file_name Response.Redirect URL else if strName1 = "asp" or strName1 = "ASP" or strName1 = "INC" or strName1 ="inc" then

response.redirect "../Error.asp?ERROR=500&EI=UPLOAD"

else

Select case strName1
case "DOC"
Response.ContentType = "application/vnd.ms-word"
case "DOCX"
Response.ContentType = "application/vnd.ms-word"
case "XLSX"
Response.ContentType = "application/vnd.ms-excel"
case "XLS"
Response.ContentType = "application/vnd.ms-excel"
Case Else
Response.ContentType = "application/unknown"
end Select

Response.AddHeader "Content-Disposition","attachment; filename=" &file_name

Set objStream = Server.CreateObject("ADODB.Stream")

objStream.Open
objStream.Type = 1

objStream.LoadFromFile URL
download = objStream.Read
Set objstream = nothing

Response.BinaryWrite download

end if
end if
else
response.write "파일이 존재 하지 않습니다."
end if
%>

참조 : http://www.aspsnippets.com/Articles/Save-Files-to-SQL-Server-Database-using-FileUpload-Control.aspx

다운로드시 10M 이상 다운로드 안될때 // IIS 서비스 재시작
C:\WINDOWS\system32\inetsrv
MetaBase.xml 열어 수정 (범퍼/업로드)

AspBufferingLimit=”10240000″ => AspBufferingLimit=”20240000″
AspMaxRequestEntityAllowed=”4240000″ => spMaxRequestEntityAllowed=”20240000″

[asp] sql Injection 방지 함수

저장프로시저 추척을 권장하나 수정할게 많으면 차후 차근차근 수정 하고 임시로 아래와 같이 한다.

다음 파일을 include

 

[asp] replace 콤마 comma

Replace(str, “,”, ” “, 1)

ASP 파일 읽기

Const filePath = “D:\List.xml” Dim fso set fso = server.createObject(“Scripting.FileSystemObject”)

if fso.FileExists(filePath) then set textStream = fso.OpenTextFile(filePath, 1, false) Dim contents contents = textStream.ReadAll Response.write contents textStream.Close set textStream = nothing else Response.write “Error” end if set fso = nothing