Hi,
I have this ASP code, for uploading files. I can upload an image,but cannot retrieve other form element data, can anyone suggest me a way out? For eg, I have a form wherein I am getting some info from the user and he needs to upload an image as well. The code I use can upload the image but cannot get the other info. form the form fields. The code to upload is:



<%
Option Explicit
Response.Expires = 0

Server.ScriptTimeout = 1000 'Time-out limit for the file upload in seconds
Const lngUploadLimit = 30000000 Const strPageToContinue = "TargetPage.asp" Const intTypeOfPageContinue = 0 Const strUploadFolder = "Uploaded/"
Const intVerbose = 1
%>
<!--#INCLUDE FILE="modMimeFunctions.asp" -->
<%
Dim strDate
strDate = Now()

Response.Write "<BR>Upload started: " & strDate & "<BR>"

Dim lngBytesReceived, arrMimeData, lngItemIndex
Dim strActualFileOrValue, strSaveName

Dim strName

lngBytesReceived = Request.TotalBytes

If lngBytesReceived > lngUploadLimit Then
Response.Write("<DIV ALIGN=""CENTER""><B>Sorry, your request cannot be completed because:<BR><BR>Maximum allowed size for the file is " & GetRoundedKB(lngUploadLimit) & " KB. Your request: " & GetRoundedKB(lngBytesReceived) & " KB</DIV>")
Response.Write("<META HTTP-EQUIV=""REFRESH"" CONTENT=""3; URL=javascript:history.go(-1)"">")
Response.End
End If

If lngBytesReceived > 0 Then 'Data has been received
%>
<DIV ALIGN="CENTER"><IMG SRC="images/processing.gif"><BR>File is uploading... Please wait...</DIV>
<FORM NAME="frmUpload">
<%

arrMimeData = GetMimeArray()

For lngItemIndex = 0 To UBound(arrMimeData)

strActualFileOrValue = GetMimeValue(arrMimeData(lngItemIndex))

If GetMimeContentType(arrMimeData(lngItemIndex)) = "" Or GetMimeFilename(arrMimeData(lngItemIndex)) = "" Then 'No Content-type Or filename found

strName = GetMimeName(arrMimeData(lngItemIndex))

Response.Write("<INPUT TYPE=""HIDDEN"" NAME=""" & strName & """ VALUE=""" & Server.HTMLEncode(strActualFileOrValue) & """>" & vbCrLf)

'Response.Write "<B>=== ERROR: Not a file</B><BR>"
'Response.Write "--- Data Submitted: <B>" & strActualFileOrValue & "</B>"
'Response.Write " (Length=" & Len(strActualFileOrValue) & ")<BR>"

Else 'Content-type and filename found

'Get the name of the variable
strName = GetMimeName(arrMimeData(lngItemIndex))
strSaveName = GetFilenameFromPath(GetMimeFilename(arrMimeData(lngItemIndex))) 'Use original filename

'strSaveName = GenerateRandomName(strSaveName)

Response.Write("<INPUT TYPE=""HIDDEN"" NAME=""" & strName & """ VALUE=""" & strSaveName & """>" & vbCrLf)

Call WriteFile(strActualFileOrValue, Server.MapPath(strUploadFolder & strSaveName))
If intVerbose = 1 Then Response.Write("<FONT COLOR=""RED"">" & strSaveName & "</FONT> (" & GetRoundedKB(Len(strActualFileOrValue)) & " KB)<BR>")

End If
Next
End If

Response.Write "<BR><BR>Upload complete: " & Now()
Response.Write "<BR>Speed: " & GetRoundedKBperS(lngBytesReceived, DateDiff("s", strDate, Now())) & " KB/s"


%>



modMimeFunctions.asp

<%
Function GetMimeHeader(strMime)

Dim intDataStart, strHeader

intDataStart = InStr(strMime, vbCrLf & vbCrLf)
If intDataStart > 0 Then 'Header boundary found
'Parse header and return
GetMimeHeader = Left(strMime, intDataStart - 1)
End If

End Function

Function GetMimeArray()

Dim strSignature, strCompleteData, lngTotalBytes, lngBytesRead, lngChunkSize, objSourceData

lngChunkSize = 5242880 '5 MB
lngBytesRead = 0

If Request.ServerVariables("REQUEST_METHOD") = "POST" And LCase(Left(Request.ServerVariables("HTTP_Content_Type"), 19)) = "multipart/form-data" Then
lngTotalBytes = Request.TotalBytes

Set objSourceData = CreateObject("ADODB.Stream")
objSourceData.Open
objSourceData.Type = 1 'Binary

Do While lngBytesRead < lngTotalBytes And Response.IsClientConnected
reading
If lngChunkSize + lngBytesRead > lngTotalBytes Then lngChunkSize = lngTotalBytes - lngBytesRead

objSourceData.Write(Request.BinaryRead(lngChunkSize))

lngBytesRead = lngBytesRead + lngChunkSize
Loop

objSourceData.Position = 0
strCompleteData = GetStringFromBinary(objSourceData.Read)

Set objSourceData = Nothing


strSignature = Left(strCompleteData, InStr(strCompleteData, vbCrLf) + 1)

strCompleteData = Mid(strCompleteData, InStr(strCompleteData, vbCrLf) + 2, Len(strCompleteData) - 2 - 2 * Len(strSignature))

GetMimeArray = Split(strCompleteData, strSignature)
Else 'Return empty array
GetMimeArray = Split("")
End If

End Function

Function GetStringFromBinary(strBinaryData)

Dim Rs, lngBinaryLength
Const adLongVarChar = 201

lngBinaryLength = LenB(strBinaryData)

If lngBinaryLength = 0 Then Exit Function

VT_ARRAY first
If VarType(strBinaryData) = 8 Then strBinaryData = MultiByteToBinary(strBinaryData)

Set Rs = CreateObject("ADODB.Recordset")

Rs.Fields.Append "tmpBinField", adLongVarChar, lngBinaryLength 'Create temp field
Rs.Open
Rs.AddNew
Rs("tmpBinField").AppendChunk strBinaryData 'Add binary data to temp table
Rs.Update

GetStringFromBinary = Rs("tmpBinField") 'Get string and return it

Set Rs = Nothing

End Function

Function GetBinaryFromMultiByte(strMultiByte)

Dim Rs, lngMultiByteLength
Const adLongVarBinary = 205

lngMultiByteLength = LenB(strMultiByte)

If lngMultiByteLength = 0 Then Exit Function

Set Rs = CreateObject("ADODB.Recordset")

Rs.Fields.Append "tmpBinField", adLongVarBinary, lngMultiByteLength 'Create temp field
Rs.Open
Rs.AddNew
Rs("tmpBinField").AppendChunk strMultiByte & ChrB(0) 'Add multibyte data to temp table
Rs.Update

GetBinaryFromMultiByte = Rs("tmpBinField").GetChunk(lngMultiByteLength) 'Get binary data and return it

Set Rs = Nothing

End Function

Function GetMimeContentDisposition(strMime)

GetMimeContentDisposition = GetMimeValueByCoord(strMime, "Content-Disposition:", ";")

End Function

Function GetMimeContentType(strMime)

GetMimeContentType = GetMimeValueByCoord(strMime, "Content-Type:", vbCrLf)

End Function

Function GetMimeFilename(strMime)

GetMimeFilename = GetMimeValueByCoord(strMime, "filename=""", """")

End Function

Function GetMimeName(strMime)

GetMimeName = GetMimeValueByCoord(strMime, "name=""", """")

End Function

Function GetMimeValue(strMime)

Dim intBeg

intBeg = InStr(1, strMime, vbCrLf & vbCrLf) + Len(vbCrLf & vbCrLf)

If intBeg > 0 Then
GetMimeValue = Mid(strMime, intBeg, Len(strMime) - intBeg - 1)
End If

End Function

Function GetMimeValueByCoord(strMime, strLeftBound, strRightBound)

Dim intBeg, intEnd, strHeader

strHeader = GetMimeHeader(strMime)

intBeg = InStr(1, strHeader, strLeftBound)

If intBeg > 0 Then 'Value name found in header, parse value
intBeg = intBeg + Len(strLeftBound)
intEnd = InStr(intBeg, strMime, strRightBound)

If intEnd = 0 Then intEnd = Len(strMime)

'Return found value
GetMimeValueByCoord = Trim(Mid(strMime, intBeg, intEnd - intBeg))
End If

End Function

Function GetMimeValueByName(arrMime, strValueName)

Dim intI, intBeg, strHeader

'Search all items of array
For intI = 0 To UBound(arrMime)

'Get header
strHeader = GetMimeHeader(arrMime(intI))
If strHeader <> "" Then 'Header found
'Search for value name in header
intBeg = InStr(1, strHeader, "name=""" & strValueName & """")
If intBeg > 0 Then 'Value name found in header, parse value
intBeg = intBeg + Len("name=""" & strValueName & """") + Len(vbCrLf & vbCrLf)

'Return found value
GetMimeValueByName = Mid(arrMime(intI), intBeg, Len(arrMime(intI)) - intBeg - 1)
Exit For
End If
End If
Next

End Function

Function GetFilenameFromPath(strPath)

Dim intI

intI = InStrRev(strPath, "\")
If intI > 0 Then
GetFilenameFromPath = Mid(strPath, intI + 1)
Else
GetFilenameFromPath = strPath
End If

End Function


Sub WriteFile(strFileData, strSavePath)

Dim objFSO, objTextStream

If Len(strFileData) = 0 Then Exit Sub

'Create objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.CreateTextFile(strSavePath, True, False)

'Write file and close it
objTextStream.Write strFileData
objTextStream.Close

'Delete objects
Set objTextStream = Nothing
Set objFSO = Nothing

End Sub

Sub DeleteFile(strPath)

Dim objFSO, tmpFileHandle

'Create object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Delete zoom image
If objFSO.FileExists(strPath) Then
Set tmpFileHandle = objFSO.GetFile(strPath)
tmpFileHandle.Delete
End If

'Delete objects
Set tmpFileHandle = Nothing
Set objFSO = Nothing

End Sub

Function GenerateRandomName(strFileName)

Dim strDate

'Remove illegal characters for a filename
strDate = Year(Now) & "." & String(2 - Len(Month(Now)), "0") & Month(Now) & "." & String(2 - Len(Day(Now)), "0") & Day(Now)

Randomize

'Return
GenerateRandomName = strDate & "_" & CStr(Round(Rnd * 1000000)) & Mid(strFileName, InStrRev(strFileName, ".")) 'Date_RandomNumber.EXT

End Function

Function GetRoundedKB(lngByteAmount)

GetRoundedKB = FormatNumber(Int(lngByteAmount / 1024 * 100 + 0.5) / 100, 2)

End Function

Function GetRoundedKBperS(lngByteAmount, lngSecondsElapsed)

'Error check
If lngSecondsElapsed <= 0 Then lngSecondsElapsed = 1

GetRoundedKBperS = FormatNumber(Int(lngByteAmount / 1024 / lngSecondsElapsed * 100 + 0.5) / 100, 2)

End Function

%>