以下為本站文章分類清單

  1. AJAXspacer
  2. ASPspacer
  3. CSSspacer
  4. Javascriptspacer
  5. Windows 應用程式spacer
  6. 網頁設計
  7. 評論、短文、雜文spacer
  8. 版主spacer
  9. 最新回應spacer

以下為本頁本文內容

簡單 ADODB Stream 應用例

許多例子,都是使用 Stream 物件來當作下載用途,目的是隱藏下檔檔案來源。這個方法在 Windows 2003 IIS6 中對 asp 的限制,只能作 4MB 大小檔案傳輸,對 aspx 則似乎沒有限制。

不用 asp 的用戶不用心焦,找到伺服器中的這個檔案 \Windows\System32\Inetsrv\Metabase.xml,把 AspBufferingLimit 值改掉即可。

以下,展示一個程式例,可以用來執行下載,或顯示圖片影音檔案,例如:

<img src="s.asp?f=CrossBrowser.png" border="0">

執行例如:

也可以拿來作下載功用,如,按我下載上圖。連結語法則為:

<a href="s.asp?f=CrossBrowser.png">按我下載上圖</a>

剩下的,就是你參數 f 只傳了檔名,那實際檔案在那呢?自己安排吧,如下面程式碼,filename 即為來源指定。

還想到什麼嗎?沒錯,用來製作影音檔!自己試試吧!

filename=Server.MapPath("images/"&Request.QueryString("f"))
Set fso = Server.CreateObject("Scripting.FileSystemObject")

'簡查檔案是否存在
If fso.FileExists(filename) Then

'取得檔案資料
Set objFile = fso.GetFile(filename)
Response.Clear

'使用者接收設定
Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"

'建立 ADODB Stream 物件
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open

'二進位方式傳送
objStream.Type = 1

'設定編碼
Response.CharSet = "UTF-8"

'載入檔案
objStream.LoadFromFile(filename)

'二進為方式傳送
Response.BinaryWrite(objStream.Read)

'完成,關閉物件
objStream.Close
Set objStream = Nothing
Set objFile = Nothing

Else

Response.Clear
Response.Write("檔案不存在")

End If
Set fso = Nothing

下載本文 asp 原始檔

卜維丰 2/2 07'

以下為文章回應區

同意轉載,不過麻煩看一下轉載需知

irmamorando.bravesites.com   2017/5/7 下午 04:46:00

Stunning story there. What happened after? Good luck!

lamictal 50 mg   2017/5/4 上午 07:43:00

you're actually a just right webmaster. The site loading pace
is incredible. It kind of feels that you are doing any unique trick.
Moreover, The contents are masterwork. you have performed
a wonderful activity on this matter!

manicure   2017/5/4 上午 04:13:00

Hello! I know this is kind of off topic but I was wondering which blog
platform are you using for this site? I'm getting
sick and tired of Wordpress because I've had problems with hackers and I'm looking
at alternatives for another platform. I would be awesome if you could point me
in the direction of a good platform.

manicure   2017/4/11 下午 06:10:00

Hello everybody, here every one is sharing these kinds of familiarity, so it's good to read this weblog, and I used to
pay a visit this blog everyday.

卜維丰   2011/7/17 下午 02:35:00

Zero, sky

我是沒遇, 你們可試試 UTF-8 編碼

zero   2011/6/28 下午 05:39:00

我與sky的問題相同,若檔名為中文時,由於變成亂碼因此會一直顯示出檔案不存在...

我將檔名先Server.UrlEncode("中文檔名")....不會出錯,但是檔名變成"中文檔名.pdf[1]" ....不知為何後面都會多出[1].....

不知是否有解決方案呢!? 謝謝 ^^

MotoJ   2010/2/10 下午 08:56:00

我新手請教一下,

如果要把上傳的檔案以二進位的方式變成字串,然後顯示在網頁上,要怎麼改呢?

謝謝指教!

aluba_new@msn.com

sky   2009/5/27 上午 11:09:00

請教一下,若本身檔名命名為中文那麼下載時將會出現錯誤,無法下載也.如此種方式如何決解ths

卜維丰   2008/5/8 下午 09:22:00

底下這篇, 說是廣告信先鋒部隊, 不過滿好笑的, 大致翻譯給各位看看....

一個下午, 我在後院晾衣服, 一隻看起來又老又累的狗跑進我院子, 我由他的項圈和凸出來的肚子可以得知, 這是有人養的狗.

當我回屋裡時, 他跟了進來, 然後從容的躺在角落睡覺, 一小時後, 他走到到門口, 我讓他離開, 隔天, 他又回來了, 躺在同一個地方又睡了一小時, 這種情況持續了好幾周.

我很好奇, 於是在他的項圈上別了張紙條寫"你家的狗每天下午跑到我這裡來小憇片刻", 隔天, 他的項圈上別了另一張紙條回來"他生活在一個有十個小孩子的家庭, 他試著要補眠"

我笑到飆淚!
抱歉, 沒按規定留言

Melissik   2008/5/8 下午 08:14:00

One afternoon, I was in the backyard hanging the laundry when an old, tired-looking dog wandered into the yard.
I could tell from his collar and well-fed belly that he had a home. But when I walked into the house, he followed me, sauntered down the hall and fell asleep in a corner. An hour later, he went to the door, and I let him out. The next day he was back. He resumed his position in the hallway and slept for an hour.
This continued for several weeks. Curious, I pinned a note to his collar: "Every afternoon your dog comes to my house for a nap. "
The next day he arrived with a different note pinned to his collar: "He lives in a home with ten children - he's trying to catch up on his sleep."

I cried from laughter
Sorry, if not left a message on Rules.

給個回應
姓名:
佈落格網址:
  如果您是要發問問題, 最好有個問題測試的網址, 這樣比較容易找到您問題所在, 謝謝
內容: