Question:


Is it possible to submit two files (i.e. one image and one zip) and have them go into different directories?

Answer:


I was able to do this by adding the following lines to the “incPureUpload.asp” file after the “Get the path” on line 149. I’m putting zip files in one folder and images in the other by setting the varExt with the last 3 characters of the file name (the extension) and using it to set my path variable varPath with “If” statements.

'Get the path
GP_CurFileName = UploadRequest.Item (GP_curKey).Item("FileName")
Dim varExt
Dim varPath
varExt =Right(GP_CurFileName,3)
If varExt = "zip" Then
varPath = "Maps"
Else
varPath = "Pics"
End If

*And added (& varPath & “\”) to lines 162 and 169 (new line numbers after adding above code)

if InStr(UploadDirectory,"\") > 0 then
GP_curPath = UploadDirectory
if Mid(GP_curPath,Len(GP_curPath),1) <> "\" then
GP_curPath = GP_curPath & "\" & varPath & "\"    <<Added Code here
end if
GP_FullPath = GP_curPath
else
GP_curPath = Request.ServerVariables("PATH_INFO")
GP_curPath = Trim(Mid(GP_curPath,1,InStrRev(GP_curPath,"/")) & UploadDirectory)
if Mid(GP_curPath,Len(GP_curPath),1) <> "/" then
GP_curPath = GP_curPath & "/" & varPath & "/"     <<Added Code here
end if
GP_FullPath = Trim(Server.mappath(GP_curPath))
end if

You can get more creative with the “If Than” statements to direct multiple file types. The key is using the “GP_CurFileName” variable to set your criteria and that it is on the correct line so that the form will loop through each file name. I’m using the Right(GP_CurFileName,3) so that I can sort by file extension, but you can use any string manipulation that you prefer, such as Left( , ), InStr( , ), InStrRev( , ).

Hope this helps.
JimC