許多例子,都是使用 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")) '簡查檔案是否存在
Else
End If |
卜維丰 2/2 07'
同意轉載,不過麻煩看一下轉載需知
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.
![]()