1. Save it to the server
<%
Dim id_srl 'request. querystring ("id_srl ")
Id_srl = 49
If CINT (id_srl)> 0 then
Dim Conn, connstr, RS, SQL, mystream
Connstr = "provider = sqloledb.1; persist Security info = false; user id = fdp_user; initial catalog = FDP; Data Source = 10.120.120.153; locale identifier = 1036; Connect timeout = 15; use procedure for prepare = 1; Auto translate = true; packet size = 4096 ;"
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open connstr, "fdp_user", "rlxhamster"
SQL = "select * From srl_contenu where id_srl =" & id_srl
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open SQL, Conn, 1, 3
Set objstream = server. Createobject ("ADODB. Stream ")
Objstream. type = 1
Objstream. Open
Objstream. Write RS ("contenu"). getchunk (RS ("contenu"). ActualSize-78)
Objstream. savetofile server. mappath ("DB") & "\" & RS ("nom_fichier"), 2
Set FSO = server. Createobject ("scripting. FileSystemObject ")
If FSO. fileexists (server. mappath ("DB") & "\" & RS ("nom_fichier") = true then
Response. Write "file" & RS ("nom_fichier") & "saved success !! "
End if
Objstream. Close
Set objstream = nothing
Rs. Close
Set rs = nothing
Conn. Close
Set conn = nothing
End if
%>
2. File Download example
<%
'Set the file size and Mime Type
Function setfordisplay (field, contenttype)
Contenttype = lcase (TRIM (contenttype ))
Nfieldsize = field. actualsize
Bytes = field. getchunk (nfieldsize)
Session ("bytes") = bytes
Session ("type") = contenttype
End Function
Function setfilesize (field)
Nfieldsize = field. actualsize
Setfilesize = field. getchunk (nfieldsize)
End Function
Setfordisplay RS ("contenu"), RS ("content_type ")
Response. addheader "content-disposition", "attachment; filename =" & RS ("nom_fichier ")
Response. contenttype = SESSION ("type ")
Response. binarywrite SESSION ("bytes ")
Session ("type") = ""
Session ("bytes") = ""
%>