问题描述
我使用以下代码隐藏我网站上的文件下载URL。代码使用Response.Binarywrite将文件发送到客户端。
请指出使用此方法可以下载的文件的最大大小。
我正在托管此站点在公共服务器上,所以我将无法在Web服务器上进行任何更改。请指出可以采取哪些措施来确保上述方法对于任何文件大小下载仍然有效。
调用Response.AddHeader(" Content-Disposition"," attachment; filename = """& strFileSave&"""")
Response.ContentType =" bad / type"
设置Fsys =服务器.CreateObject(" Scripting.FileSystemObject")
设置TS = Fsys.GetFile(strFile).OpenAsTextStream(1,-1)
Do While Not(TS.AtEndOfStream )
Response.BinaryWrite(TS.Read(1))
循环
I am using the following code to hide the download url of files on my website. The code uses Response.Binarywrite to send file to the client.
Kindly indicate the maximum size of the file that can be downloaded using this method.
I am hosting this site on a public server, so I will not be able to change anything on the webserver. Kindly indicate what can be done to ensure that the above method remains valid for any file size download.
call Response.AddHeader("Content-Disposition","attachment; filename=""" & strFileSave & """")
Response.ContentType = "bad/type"
Set Fsys = Server.CreateObject("Scripting.FileSystemObject")
Set TS = Fsys.GetFile(strFile).OpenAsTextStream(1, -1)
Do While Not (TS.AtEndOfStream)
Response.BinaryWrite(TS.Read(1))
Loop
推荐答案
嗯......无论如何,那段代码都不适合工作。看方法
OpenAsTEXTstream
???
你真的只能可靠地使用FileSystemObject和文本文件;它不是用于处理二进制文件的
。
您需要使用ADODB.Stream对象。
http://msdn.microsoft.com/en- us / libr ... 32(VS.85).aspx
然后你可以通过
$轻松控制你在每个块中写的金额b $ b限制您每次阅读的金额。
Ummm...that code isn''t goint to work, anyway. See the method
OpenAsTEXTstream
???
You really can only use FileSystemObject reliably with text files; it wasn''t
designed to work with binary files.
You need to use ADODB.Stream object, instead.
http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx
And then you could easily control the amount you write in each chunk by just
limiting the amount you Read each time.
嗯......无论如何,代码都不适合工作。看方法
OpenAsTEXTstream
???
你真的只能可靠地使用FileSystemObject和文本文件;它是
不是
设计用于处理二进制文件。
您需要使用ADODB.Stream对象,而不是。
然后你可以很容易地控制你在每个中写的金额大块由
只是
限制你每次读取的金额。
Ummm...that code isn''t goint to work, anyway. See the method
OpenAsTEXTstream
???
You really can only use FileSystemObject reliably with text files; it
wasn''t
designed to work with binary files.
You need to use ADODB.Stream object, instead.
http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx
And then you could easily control the amount you write in each chunk by
just
limiting the amount you Read each time.
好旧的Atrax有几个演示。
请注意,他的代码是用JScript编写的ASP,但转换到VBScript
应该很容易。
和
如果您需要更多帮助,请询问。
Good old Atrax has a couple of demos.
Note that his code is written in JScript for ASP, but conversion to VBScript
should be easy.
http://rtfm.atrax.co.uk/infinitemonk...es/asp/934.asp
and
http://rtfm.atrax.co.uk/infinitemonk...es/asp/935.asp
If you need more help, ask.
这篇关于Response.binarywrite中的文件大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!