Advertisement
4_2005-2006 Classes/ Frameworks/ OOP #165293

Simple Download Method with Streams

Enables you to put a certain degree of protection in files available for download in you IIS Server by making them inaccessible by a direct URL. Hides them in other directory, out of wwwroot.

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
<%
	'-- DOWNLOAD.ASP
	'
	'-- Simple Download Method with Streams
	' Daniel Verzellesi
	'
	' As an example I'm getting the file I want to download
	' from the Request (//.../dowload.asp?fname=myfile1.doc).
	' You can change it to get the file name from a DB or
	' anything else...
	'
	Dim p, st, f
	'-- my "secret" path
	p = "c:\files\"
	'-- file name
	f = Request.QueryString("fname")
	'-- get file into stream
	Set st = CreateObject("ADODB.Stream")
	st.Open
	st.Type = 1 'binary
	st.LoadFromFile p & f
	'-- send stream to response
	Response.ContentType = "application/my-download"
	Response.AddHeader "Content-Disposition", "attachment; filename=""" & f & """"
	Response.BinaryWrite st.Read(-1) 'read all
	Response.End 
	'-- close the stream
	set st = nothing
%>
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine