ASP不支持multipart/form-data編碼方式,但是,Microsoft提供了免費的Posting Acceptor(http://www.microsoft.com/iis/support/iishelp/iis/htm/core/pareadme.htm),它是一個ISAPI應用程序,上載結束后,產生一個到ASP頁的重新投遞。(見 Scott Stanfield的文章 issue of MIND(98年七月))。
Software Artisans的SA-FileUp
SA-FileUp(http://www.softartisans.com/softartisans/saf.html)是最早的商業活動服務器組件(Active Server Components)之一。第一版是97年5月開始使用的,現在全世界包括Microsoft.com在內的上千個網站都在使用它。早期的Beta版本用ISAPI過濾器和活動服務器組件的聯合體與ASP結合起來。接著,Microsoft推出了ASP 1.0b(ASP.DLL 1.15.14.0),提供了一種新方法:Request.BinaryRead(二進制讀請求)。二進制讀方法使瀏覽器中的原始未加工數據可以被活動服務器組件使用。這樣一來,SA-FileUp就不再需要ISAPI過濾器,而作為一個ASP組件存在了。
Enter first filename: < input type="file" name="f1" > Enter second filename: < input type="file" name="f2" > 格式處理是一樣的:
< %@ LANGUAGE="VBSCRIPT" % > < HTML >< HEAD > < TITLE >Multiple File Upload Results< /TITLE > < /HEAD > < BODY > Thank you for uploading your files. < % Set upl = Server.CreateObject("SoftArtisans.FileUp") % > < % upl.Form("f1").SaveAs "C: empupload1.out" % > Total Bytes Written for file 1: < %=upl.Form("f1").TotalBytes% > < % upl.Form("f2").SaveAs "C: empupload2.out" % > Total Bytes Written for file 2: < %=upl.Form("f2").TotalBytes% > < /BODY > < /HTML > 限制上載規模
要限制上載規模,只需要設置一個屬性:
< %@ LANGUAGE="VBSCRIPT" % > < HTML >< HEAD > < TITLE >Upload File Results< /TITLE > < /HEAD > < BODY > Thank you for uploading your file. < % Set upl = Server.CreateObject("SoftArtisans.FileUp") % > < % upl.MaxBytes = 1000 '--- limit the upload size to 1000 bytes % > The maximum size that you are permitted to upload is < %=upl.MaxBytes% > bytes per file. < % upl.SaveAs "C: empupload.out" % > Total Bytes Written: < %=upl.TotalBytes% > Server Filename: < %=upl.ServerName% > Total Bytes Transmitted by you: < %=Request.TotalBytes% > < /BODY > < /HTML > 第1000個字節后的內容都將被刪除,WEB服務器的磁盤就不會不必要地被占滿。