Can I upload to multiple directories? Support
Is it possible to submit two files (i.e. one image and one zip) and have them go into different directories?
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")
If varExt = "zip" Then
varPath = "Maps"
varPath = "Pics"
*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
GP_FullPath = GP_curPath
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
GP_FullPath = Trim(Server.mappath(GP_curPath))
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.