以前收集的一些资料---不用组件上载文件代码(二)

文件futils.inc
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
'True PureASP upload - enables save of uploaded text fields to the disk.
'c1997-1999 Antonin Foller, PSTRUH Software, http://www.pstruh.cz
'The file is part of ScriptUtilities library
'The file enables http upload to ASP without any components.
'But there is a small problem - ASP does not allow save binary data to the disk.
' So you can use the upload for :
' 1. Upload small text (or HTML) files to server-side disk (Save the data by filesystem object)
' 2. Upload binary/text files of any size to server-side database (RS("BinField") = Upload("FormField").Value

'All uploaded files and log file will be saved to the next folder :
Dim LogFolder
LogFolder = Server.MapPath(".")

'********************************** SaveUpload **********************************
'This function creates folder and saves contents of the source fields to the disk.
'The fields are saved as files with names of form-field names.
'Also writes one line to the log file with basic informations about upload.
Function SaveUpload(Fields, DestinationFolder, LogFolder)
  if DestinationFolder = "" then DestinationFolder = Server.MapPath(".")

  Dim UploadNumber, OutFileName, FS, OutFolder, TimeName, Field
  Dim LogLine, pLogLine, OutLine

  'Create unique upload folder
  Application.Lock
    if Application("UploadNumber") = "" then
      Application("UploadNumber") = 1
    else
      Application("UploadNumber") = Application("UploadNumber") + 1
    end if
    UploadNumber = Application("UploadNumber")
  Application.UnLock

  TimeName = Right("0" & Year(Now), 2) & Right("0" & Month(Now), 2) & Right("0" & Day(Now), 2) & "_" & Right("0" & Hour(Now), 2) & Right("0" & Minute(Now), 2) & Right("0" & Second(Now), 2) & "-" & UploadNumber
  Set FS = CreateObject("Scripting.FileSystemObject")
  Set OutFolder = FS.CreateFolder(DestinationFolder + "\" + TimeName)

  Dim TextStream
  'Save the uploaded fields and create log line
  For Each Field In Fields.Items
    'Write content of the field to the disk
    '!!!! This function uses FileSystemObject to save the file. !!!!!
    'So you can only use text files to upload. Save binary files by the function takes undefined results.
    'To upload binary files see ScriptUtilities, http://www.pstruh.cz

    'You can save files with original file names :
    'Set TextStream = FS.CreateTextFile(OutFolder & "\" & Field.FileName )
    
    'Or with names of the fields
    Set TextStream = FS.CreateTextFile(OutFolder & "\" & Field.Name & ".")

        'And this is the problem why only short text files - BinaryToString uses char-to-char conversion. It takes a lot of computer time.
    TextStream.Write BinaryToString(Field.Value) ' BinaryToString is in upload.inc.
    TextStream.Close
    

    'Create log line with info about the field
    LogLine = LogLine & """" & LogF(Field.name) & LogSeparator & LogF(Field.Length) & LogSeparator & LogF(Field.ContentDisposition) & LogSeparator & LogF(Field.FileName) & LogSeparator & LogF(Field.ContentType) & """" & LogSeparator
  Next
  
  'Creates line with global request info
  pLogLine = pLogLine & Request.ServerVariables("REMOTE_ADDR") & LogSeparator
  pLogLine = pLogLine & LogF(Request.ServerVariables("LOGON_USER")) & LogSeparator
  pLogLine = pLogLine & Request.ServerVariables("HTTP_Content_Length") & LogSeparator
  pLogLine = pLogLine & OutFolder & LogSeparator
  pLogLine = pLogLine & LogLine
  pLogLine = pLogLine & LogF(Request.ServerVariables("HTTP_USER_AGENT")) &

时间: 2024-09-05 17:04:51

以前收集的一些资料---不用组件上载文件代码(二)的相关文章

以前收集的一些资料---不用组件上载文件代码段(三)

文件fformat.inc<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT> function Foot()  DIM HTML    HTML = "<hr><Table Border=0 Width=100%><TR><TD><font size=1>燬ample upload/download via ASP from <a href=http://www.pstruh.cz>P

以前收集的一些资料---不用组件上载文件代码具体例子

下面的第一个例子为只是将客户端的文件上传到服务端的例子第二个例子为将文件内容保存入数据库中.文件fupload.asp<%dim ResultHTML'Some value greater than default of 60s (According to upload size.)'The maximum speed is about 100kB/s for IIS4, P200 and local upload, 4kB/s for modem users.Server.ScriptTime

深入研究“用ASP上载文件”(转)(二)

二.在ASP中执行现在已经得出结论,RFC1867是在WEB应用程序上载文件的最好方式.那么如何来运行?Microsoft提供了什么方法?其它有哪些方法可以用? Microsoft的Posting Acceptor ASP不支持multipart/form-data编码方式,但是,Microsoft提供了免费的Posting Acceptor(http://www.microsoft.com/iis/support/iishelp/iis/htm/core/pareadme.htm),它是一个I

用ASP和VBScript上载文件(二)

vbscript|vbscript 上载脚本的使用       下面是开发的上载脚本的应用范例.本文的下载文件提供例子中的文件和代码.将压缩文件释放到一个路径下,为你的网络服务器配置一个虚拟路径.可以在浏览器中测试和启动uploadForm.html.      调用脚本       下面是调用上载BuildUploadRequest 方法的途径.首先调用一个全程dictionary:UploadRequest.然后调用BuilUploadRequest方法,然后在自变量中传送到请求原始二进制数

以前收集的一些资料---使用组件技术来保护你的ASP代码

               使用组件来保护你的ASP代码以前大家谈了很多有关打开数据库连接安全的问题,现在我再提出一种思路使用ActiveX DLL来保护你的代码.(既可以不用为使用共享的加密软件而发愁,更重要的是可以自己来顶制加密方法了,享受一下"一切尽在掌握之中"的感觉.同时也为了让大家都自己动手来做出自己的组件来.)ActiveX DLLs是被编译过的机器代码,如果没有源项目文件的话是不能够被编译的.这个技术使得开发者有可能开发出公共的自动化程序,并且把它们作为sharewar

不用组件如何控制.flv音量大小

控制 好些网友PM我问:"要是不用组件怎么控制.flv 的音量呢?"其实都很简单的,跟控制MP3音量都是一箩子的事-//:::::*****夏日之夜(Guoyl)*****::::: // :::::*****QQ:190603050*****::::: var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); myVideo.attachVid

以前收集的一些资料---使用ASP加密算法加密你的数据(二)

加密|数据|算法          以前收集的一些资料---使用ASP加密算法加密你的数据(二)Julain Sitkewich在第一部分,讨论了如何生成密钥,下面将介绍如何使用这个密钥来加密和解密一个字符串.下面的代码就是能够同时实现这个功能的函数Crypt.asp文件<% Dim g_Key Const g_CryptThis = "Now is the time for all good men to come to the aid of their country."Co

谷歌被要求立即删除在澳门街道收集的敏感资料

新华社澳门3月6日电(记者刘冬杰)澳门特区个人资料保护办公室http://www.aliyun.com/zixun/aggregation/38628.html">新闻发言人杨崇蔚6日向新华社记者证实,由于美国谷歌公司未经许可非法收集澳门街道及个人的影像数据,并将所收集的WiFi资料转移到美国,违反了特区个人资料保护法侵害了当事人的权益,因此决定对谷歌公司处以3万澳门元的罚款,并责成该公司删除在澳门街道收集的敏感资料. 据介绍,谷歌的"街景服务"专车2008年12月10

使用JSP/Servlet上载文件

js|servlet 使用 JSP/ Servlet上载文件正成为一项常用的任务.以下是一个简单的例程,使用了jspsmart的一个免费的组件.你可以在JSPSMART站点进行下载. 1. Html File <html> <body> <script LANGUAGE="javascript" SRC="JSFunction.js"> </script> <script language="JavaS