File 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 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 your 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 would be saved to the next folder:
Dim LogFolder
LogFolder = Server.MapPath (".")
' ********************************** saveupload **********************************
' This function creates folder and saves contents's 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 can I use the text files to upload. Save binary files by the function takes undefined results.
' To upload binary files scriptutilities, http://www.pstruh.cz
' 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 a 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 ' with info about the field
Logline = logline & "" "& Logf (field.name) & Logseparator & Logf (field.length) & Logseparator & L OgF (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")) &