• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 569
  • Last Modified:

aspUpload multiple files (three or more)

Ok what I need to happen is for someone to be able upload three or more or less files.  Currently (thanks to kiddanger) I am able to do this with two file fields.
I get the following error
Persits.Upload.1 error '800a0020'

The system cannot find the file specified.

/testing/borrower/businessPlan.asp, line 79

line79=file3.CopyVirtual strPath & fp & "\" & Name & file3.Ext
Below is my code

<%@ Language=VBScript %>
<%
Set Upload = Server.CreateObject("Persits.Upload")
'dim upload, count
dim fileBusPlan, fileTaxes, file1, file2,  file3,file
dim bp, fp, name
Set upload = Server.CreateObject("Persits.Upload")
count = upload.SaveVirtual(strPath)

dim newId, strFirst, strLast
newID=loanID
strFirst=first
strLast=last
loanYear=cStr(Upload.Form("selYear1"))
bp = "\businessPlan"
fp = "\financialStatements"

set file1 = Upload.Files("fileBusplan")
set file2 = upload.files("fileTaxes")
set file3 = upload.files("fileTaxes2")
if count > 0 then
  for each file in upload.files
    if file.name = "fileBusplan" then
      Name = newid & "_" & strFirst & "_" & strLast & "_busPlan"
      file1.CopyVirtual strPath & bp & "\" & Name & file1.Ext
     busPath= strPath & bp & "\" & Name & file1.Ext
      if count > 1 then
        if file1.filename <> file2.filename  then
          file1.Delete
        end if
      else
        file1.delete
      end if
    end if

    if file.name = "fileTaxes" then
      Name = newid & "_"&loanYear&"_" & strFirst & "_" & strLast & "_01FS"
      file2.CopyVirtual strPath & fp & "\" & Name & file2.Ext
      fsPath= strPath & fp & "\" & Name & file2.Ext
      file2.Delete
    end if
      
     if file.name = "fileTaxes2" then
      Name = newid & "_"&loanYear&"_" & strFirst & "_" & strLast & "_02FS"
      file3.CopyVirtual strPath & fp & "\" & Name & file3.Ext
      fsPath2= strPath & fp & "\" & Name & file3.Ext
      file3.Delete
    end if
  next
end if%>
Please help
0
jayham
Asked:
jayham
  • 12
  • 11
  • 4
  • +1
1 Solution
 
masirofCommented:
It cannot find path, as you have understood.

I suggest you to use Server.MapPath method to point the target directory.

Server.MapPath(".") point to current folder where asp page resides, please navigate as you need.
0
 
jayhamAuthor Commented:
strPath = "\testing\borrower\uploadedFiles"
Sorry The path was in an include file
0
 
masirofCommented:
You have solved problem?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
jayhamAuthor Commented:
no, the problem is not the path
0
 
masirofCommented:
Hm, then I think it is about  If File.Exits logic?
Isnt it?

Error is the file cannot be found though..
0
 
RickDaiCommented:
well you can test 2 things...

1: make sure if the path exists.
2: make sure you have modify permission on the directory you are saving to.
0
 
jayhamAuthor Commented:
the permissions are fine
heres what i can do right now
Upload anyone of the 3 files individually
Upload file1 and file2 at the same time
The problem happens when I try to upload file3 with any combination of the other two files
0
 
jayhamAuthor Commented:
If anyone has any other sugestions, they would be greatly appreciated.
kiddanger if you have any ideas that would be great
0
 
masirofCommented:
Please post here the problematic line..
0
 
jayhamAuthor Commented:
file3.CopyVirtual strPath & fp & "\" & Name & file3.Ext
the rest of the code is above
0
 
kiddangerCommented:
Your code is somewhat different that what I offered in the other question...

Why are you using CopyVirtual as opposed to Copy?

Copy uses a physical path.
CopyVirtual expects a virtual one.

\ = physical
/ = virtual

You're setting fspath and fspath2 after you copy.  I'm not sure that's of any use.
If you set it before then you could use it to copy.

Ex.
Current:

file3.CopyVirtual strPath & fp & "\" & Name & file3.Ext
fsPath2= strPath & fp & "\" & Name & file3.Ext

Proposed:
fsPath2= strPath & fp & "\" & Name & file3.Ext
file3.Copy fsPath2
0
 
jayhamAuthor Commented:
This is the error i get
Persits.Upload.1 error '800a0028'

This feature has been disabled by system administrator. Use CopyVirtual instead.

/testing/borrower/businessPlan.asp, line 82
0
 
jayhamAuthor Commented:
With my coding above I am able to upload any of the files individually as well as files 1 and 2 together, and files 2 and 3 together. Icant do all three, or 1 and 3 together
0
 
kiddangerCommented:
Can you show your upload form?
0
 
jayhamAuthor Commented:
<!--#include file="../includes/configuration.asp" -->
<!--#include file="../includes/sessionVars.asp" -->
<%
Call openDB ()
dim loanID
loanID=request.QueryString("lnID")
ownID=request.QueryString("ownID")
strAction=request.QueryString("act")
Call openDB ()
Set Upload = Server.CreateObject("Persits.Upload")
dim upload,  count
if (Request.ServerVariables("Request_Method") <> "POST") then

if strAction="add" then
'mnyLease=cCur(0)

else
facID=request.QueryString("facID")
Call openDB ()
set objRs=objConn.execute("select * from busPlan where intLoanID="&loanID)
pkBusPlan=objRs("pkBusPlan")
strBusPlanPath=objRs("strBusPlanPath")
memDescription=objRs("memDescription")
memProducts=cstr(objRs("memProducts"))
memMarkets=objRs("memMarkets")
memMarketing=objRs("memMarketing")
memCompetitors=objRs("memCompetitors")
intCustomers=objRs("intCustomers")
intEmployees=objRs("intEmployees")
intNewEmployees=objRs("intNewEmployees")
strFSPath=objRs("strFSPath")
Call closeConnRS (objRs, objConn)
end if


else
Set Upload = Server.CreateObject("Persits.Upload")
'dim upload, count
dim fileBusPlan, fileTaxes, file1, file2,  file3,file
dim bp, fp, name
Set upload = Server.CreateObject("Persits.Upload")
count = upload.SaveVirtual(strPath)

dim newId, strFirst, strLast
newID=loanID
strFirst=first
strLast=last
loanYear=cStr(Upload.Form("selYear1"))
bp = "\businessPlan"
fp = "\financialStatements"

set file1 = Upload.Files("fileBusplan")
set file2 = upload.files("fileTaxes")
set file3 = upload.files("fileTaxes2")
if count > 0 then
  for each file in upload.files
    if file.name = "fileBusplan" then
      Name = newid & "_" & strFirst & "_" & strLast & "_busPlan"
      file1.CopyVirtual strPath & bp & "\" & Name & file1.Ext
     busPath= strPath & bp & "\" & Name & file1.Ext
      if count > 1 then
        if file1.filename <> file2.filename    then
          file1.Delete
        end if
      else
        file1.delete
      end if
    end if

    if file.name = "fileTaxes" then
      Name = newid & "_"&loanYear&"_" & strFirst & "_" & strLast & "_01FS"
      file2.CopyVirtual strPath & fp & "\" & Name & file2.Ext
      fsPath= strPath & fp & "\" & Name & file2.Ext
      file2.Delete
    end if
      
      if file.name = "fileTaxes2" then
      Name = newid & "_"&loanYear&"_" & strFirst & "_" & strLast & "_02FS"
      file3.CopyVirtual strPath & fp & "\" & Name & file3.Ext
      fsPath2= strPath & fp & "\" & Name & file3.Ext
      file3.Delete
    end if
  next
end if
pkBusPlan=cStr(Upload.Form("bpID"))      
loanID=      cStr(Upload.Form("hidLoanID"))
strBusPlanPath=busPath
memDescription=cStr(Upload.Form("memDesription"))
memProducts=cStr(Upload.Form("memProducts"))
memMarkets=cStr(Upload.Form("memMarkets"))
memMarketing=cStr(Upload.Form("memMarketing"))
memCompetitors=cStr(Upload.Form("memCompetitor"))
intCustomers=cStr(Upload.Form("selNumCustomers"))
intEmployees=cStr(Upload.Form("selNumEmployees"))
intNewEmployees=cStr(Upload.Form("selNumNewEmployees"))
strFSPath=fsPath
strFSPath2=fsPath2
Call openDB ()
            ' -- SET AND EXECUTE SQL STRING
            set rsExist=objConn.execute("select pkBusPlan from busPlan")
            set rs=objConn.execute("select max(pkBusPlan) as id from busPlan")
            if rsExist.eof then
            newid=1
            else
            newid=rs("id")+1
            end if
      if strAction="add" then
            strSQL =       "INSERT INTO busPlan (pkBusPlan,intLoanID,strBusPlanPath,memDescription,memProducts," &_
                              "memMarkets,memMarketing,memCompetitors,intCustomers,intEmployees,intNewEmployees,strFSPath,strFSPath2) VALUES " &_
                        "('" & newid & "', '" & loanID & "' , '" &strBusPlanPath& "', '" &memDescription& "', " &_
                        "'" &memProducts& "', '" &memMarkets& "', '" &memMarketing& "', '" &memCompetitors& "', '" &intCustomers& "', '" &intEmployees& "', '" &intNewEmployees& "',' " &strFSPath& "',' " &strFSPath2& "')"
            else
            if count =2  then
            strSQL =       "UPDATE busPlan SET strBusPlanPath = '" & strBusPlanPath & "', " &_
                              "memDescription= '" &memDescription  & "', " &_
                              "memProducts= '" &memProducts  & "', " &_
                              "memMarkets= '" &memMarkets  & "', " &_
                              "memMarketing= '" &memMarketing  & "', " &_
                              "memCompetitors= '" &memCompetitors  & "', " &_
                              "intCustomers= '" &intCustomers  & "', " &_
                              "intNewEmployees= " &intEmployees  & ", " &_
                              "strFSPath = '" & strFSPath & "' WHERE pkBusPlan= " & pkBusPlan
            else if count =1 and strBusPlanPath=""  then
            strSQL =       "UPDATE busPlan SET memDescription= '" &memDescription  & "', " &_
                              "memProducts= '" &memProducts  & "', " &_
                              "memMarkets= '" &memMarkets  & "', " &_
                              "memMarketing= '" &memMarketing  & "', " &_
                              "memCompetitors= '" &memCompetitors  & "', " &_
                              "intCustomers= '" &intCustomers  & "', " &_
                              "intNewEmployees= " &intEmployees  & ", " &_
                              "strFSPath = '" & strFSPath & "' WHERE pkBusPlan= " & pkBusPlan
            else if count =1 and strFSPath=""  then
            strSQL =       "UPDATE busPlan SET strBusPlanPath = '" & strBusPlanPath & "', " &_
                              "memDescription= '" &memDescription  & "', " &_
                              "memProducts= '" &memProducts  & "', " &_
                              "memMarkets= '" &memMarkets  & "', " &_
                              "memMarketing= '" &memMarketing  & "', " &_
                              "memCompetitors= '" &memCompetitors  & "', " &_
                              "intCustomers= '" &intCustomers  & "', " &_
                              "intNewEmployees= " &intEmployees  & " " &_
                              " WHERE pkBusPlan= " & pkBusPlan                                    
            else if count =0  then
            strSQL =       "UPDATE busPlan SET memDescription= '" &memDescription  & "', " &_
                              "memProducts= '" &memProducts  & "', " &_
                              "memMarkets= '" &memMarkets  & "', " &_
                              "memMarketing= '" &memMarketing  & "', " &_
                              "memCompetitors= '" &memCompetitors  & "', " &_
                              "intCustomers= '" &intCustomers  & "', " &_
                              "intNewEmployees= " &intEmployees  & " " &_
                              " WHERE pkBusPlan= " & pkBusPlan                  
            else
            strSQL =       "UPDATE busPlan SET strBusPlanPath = '" & strBusPlanPath & "', " &_
                              "memDescription= '" &memDescription  & "', " &_
                              "memProducts= '" &memProducts  & "', " &_
                              "memMarkets= '" &memMarkets  & "', " &_
                              "memMarketing= '" &memMarketing  & "', " &_
                              "memCompetitors= '" &memCompetitors  & "', " &_
                              "intCustomers= '" &intCustomers  & "', " &_
                              "intNewEmployees= " &intEmployees  & ", " &_
                              "strFSPath= " &strFSPath  & ", " &_
                              "strFSPath2 = '" & strFSPath2 & "' WHERE pkBusPlan= " & pkBusPlan            
            end if
            end if
            end if
            end if
            end if
            
            objConn.Execute (strSQL)
            Call closeConnRS (objRs, objConn)
Response.Redirect "loanProcess.asp?lnID="&loanID&""
            end if


%>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<link href="../style/ecapital.css" rel="stylesheet" type="text/css" />
</head>

<body>

<table>

<tr>
<td valign="top">
<!--#include file="leftNav.asp" -->

</td>
<td valign="top">
<form action="businessPlan.asp?lnID=<%=loanID%>&act=<%=strAction%>" method="post" name="businessPlan" id="businessPlan" enctype="multipart/form-data">
<input name="hidLoanID" type="hidden" value="<%=loanID%>" />
<input name="bpID" type="hidden" value="<%=pkBusPlan%>" />
<table>
<tr><td colspan="2">Business Plan</td></tr>
<tr><td width="30%">If you have a business plan that answers the following questions, you can attach it here and leave the remainder of this section blank:</td>
<td>
<%strt=instrrev(strBusPlanPath,"\")
response.write mid(strBusPlanPath,strt+1)

%><br />
<input name="fileBusplan" type="file" /></td>
</tr>
<tr><td valign="top">Please provide a description of your company:</td>
<td><textarea name="memDesription" cols="" rows=""><%=memDescription%></textarea></td>
</tr>
<tr><td valign="top">Please provide information about your products and services:</td>
<td><textarea name="memProducts" cols="" rows=""><%=memProducts%></textarea></td>
</tr>
<tr><td valign="top">Please provide information about your markets:</td>
<td><textarea name="memMarkets" cols="" rows=""><%=memMarkets%></textarea></td>
</tr>
<tr><td valign="top">What types of marketing are you doing at present:</td>
<td><textarea name="memMarketing" cols="" rows=""><%=memMarketing%></textarea></td>
</tr>
<tr><td valign="top">Who are your competitors and what makes you different:</td>
<td><textarea name="memCompetitor" cols="" rows=""><%=memCompetitors%></textarea></td>
</tr>
<tr><td>Number of Current active customers:</td><td>
<select name="selNumCustomers">
<%
for i = 0 to 25
i=i
%>
<option value="<%=i%>" <% IF intCustomers = i Then response.write "Selected" %>><%=i%></option>
<%next%>
</select>
</td></tr>
<tr><td>Number of current employees:</td><td>
<select name="selNumEmployees">
<%
for i = 0 to 25
i=i
%>
<option value="<%=i%>" <% IF intEmployees = i Then response.write "Selected" %>><%=i%></option>
<%next%>
</select>
</td></tr>
<tr><td>New employees to be hired after loan (please provide details):</td><td>
<select name="selNumNewEmployees">
<%
for i = 0 to 25
i=i
%>
<option value="<%=i%>" <% IF intNewEmployees = i Then response.write "Selected" %>><%=i%></option>
<%next%>
</select>
</td></tr>
<tr><td>Please provide information on your facility and location </td>
<td>
<%

Call openDB ()
set RSReal=objConn.execute("select * from facilities WHERE intLoanID=" &loanID)
if not RSReal.eof then
while not RSReal.eof%>
<a href="facilities.asp?facID=<%=RSReal("pkFacilityID")%>&act=edit&lnID=<%=loanID%>" target="_blank"><%=RSReal("strAddress")%></a><br />

<%RSReal.movenext
        wend
        end if%>




<a href="facilities.asp?lnID=<%=loanID%>&act=add" target="_blank">Add a facility</a></td>
</tr>
<tr><td>Please attach copies of your past 3 years accountant prepared financial statements or corporate tax returns here:</td>
<td>
<%strt=instrrev(strFSPath,"\")
response.write mid(strFSPath,strt+1)

%><br />
<select name="selYear1" style="width:60px;">
<%thisYr=Year(Date)-1
lateDate=thisYr - 2
for i = thisYr to lateDate Step -1
i=i
%>
<option value="<%=i%>" ><%=i%></option>
<%next%>
</select>
<input name="fileTaxes" type="file" /><br />
<select name="selYear2" style="width:60px;">
<%thisYr=Year(Date)-1
lateDate=thisYr - 2
for i = thisYr to lateDate Step -1
i=i
%>
<option value="<%=i%>" ><%=i%></option>
<%next%>
</select>
<input name="fileTaxes2" type="file" /><br />
<select name="selYear3" style="width:60px;">
<%thisYr=Year(Date)-1
lateDate=thisYr - 2
for i = thisYr to lateDate Step -1
i=i
%>
<option value="<%=i%>" ><%=i%></option>
<%next%>
</select>
<input name="fileTaxes3" type="file" /><br />

</td>
</tr>
<tr><td colspan="2" align="right"><input type="submit" name="submitLoan" value="Next"></td></tr>

</table>
</form></td>
</tr>
</table>

</body>
</html>
0
 
kiddangerCommented:
Yeeha.  I was just looking for the form but I guess this covers it.  This is different than the test page you were showing?
Also, how big are each of your files?

Why is this in there 3 times?
Set upload = Server.CreateObject("Persits.Upload")
0
 
jayhamAuthor Commented:
I thought it needed to be, maybe it does not.
Files are pretty small 100k maybe
I may have changed it a bit since first posting
0
 
kiddangerCommented:
I just modified the original and it works just fine.

Added another input field for the 3rd file and I duplicated the 2nd file routine in the post to .asp file, changing file2 to file3.  I never got an error.

test4.asp

<%@ Language=VBScript %>
<form action="test4b.asp?lnID=<%=loanID%>" method="post" name="businessPlan" id="businessPlan" enctype="multipart/form-data">
<input name="hidLoanID" type="hidden" value="<%=loanID%>" />
<table>
<tr><td colspan="2">Business Plan</td></tr>
<tr><td width="30%">If you have a business plan that answers the following questions, you can attach it here and leave the remainder of this section blank:</td>
<td><input name="fileBusplan" type="file" /></td></tr>
<tr><td valign="top">Please provide a description of your company:</td>
<td><textarea name="memDesription" cols="" rows=""></textarea></td></tr>
<tr><td valign="top">Please provide information about your products and services:</td>
<td><textarea name="memProducts" cols="" rows=""></textarea></td></tr>
<tr><td valign="top">Please provide information about your markets:</td>
<td><textarea name="memMarkets" cols="" rows=""></textarea></td>
</tr>
<tr><td valign="top">What types of marketing are you doing at present:</td>
<td><textarea name="memMarketing" cols="" rows=""></textarea></td>
</tr>
<tr><td valign="top">Who are your competitors and what makes you different:</td>
<td><textarea name="memCompetitor" cols="" rows=""></textarea></td>
</tr>
<tr><td>Number of Current active customers:</td><td>
<select name="selNumCustomers">
<%
for i = 0 to 25
  i=i
  %>
  <option value="<%=i%>" ><%=i%></option>
<%next%>
</select>
</td></tr>
<tr><td>Number of current employees:</td><td>
<select name="selNumEmployees">
<%
  for i = 0 to 25
    i=i
%>
  <option value="<%=i%>" ><%=i%></option>
<%next%>
</select>
</td></tr>
<tr><td>New employees to be hired after loan (please provide details):</td><td>
<select name="selNumNewEmployees">
<%
for i = 0 to 25
  i=i
%>
  <option value="<%=i%>" ><%=i%></option>
<%next%>
</select>
</td></tr>
<tr><td>Please provide information on your facility and location </td>
<td><a href="?ownID=<%=ownID%>" target="_blank">Add a facility</a></td>
</tr>
<tr><td>Please attach copies of your past 3 years accountant prepared financial statements or corporate tax returns here:</td>
<td><input name="fileTaxes" type="file" /></td></tr>
<tr><td>and here:</td>
<td><input name="fileTaxes2" type="file" /></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="submitLoan" value="Next"></td></tr>
</table>
</form>

test4b.asp

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True

dim upload, strPath, count
dim fileBusPlan, fileTaxes, file1, file2, file3, file
dim bp, fp, name

Set upload = Server.CreateObject("Persits.Upload.1")
strPath = "c:\domains\kiddanger.com\e"
count = upload.Save(strPath)

dim newId, strFirst, strLast
'newID=loanID
'strFirst=first
'strLast=last

bp = "\businessPlan"
fp = "\financialStatements"

set file1 = Upload.Files("fileBusplan")
set file2 = upload.files("fileTaxes")
set file3 = upload.files("fileTaxes2")

if count > 0 then
  for each file in upload.files
    if file.name = "fileBusplan" then
      Response.Write file.name & "<br />" & vbCrLf
      Upload.CreateDirectory strPath & bp, True
      Name = newid & "_" & strFirst & "_" & strLast & "_busPlan"
      file1.Copy strPath & bp & "\" & Name & file1.Ext
      Response.Write strPath & bp & "\" & Name & file1.Ext & "<br />" & vbCrLf
      if count > 1 then
        if file1.filename <> file2.filename then
          file1.Delete
        end if
      else
        file1.delete
      end if
    end if
    if file.name = "fileTaxes" then
      Response.Write file.name & "<br />" & vbCrLf
      Upload.CreateDirectory strPath & fp, True
      Name = newid & "_" & strFirst & "_" & strLast & "_FS"
      file2.Copy strPath & fp & "\" & Name & file2.Ext
      Response.Write strPath & fp & "\" & Name & file2.Ext & "<br />" & vbCrLf
      file2.Delete
    end if
    if file.name = "fileTaxes2" then
      Response.Write file.name & "<br />" & vbCrLf
      Upload.CreateDirectory strPath & fp, True
      Name = newid & "_" & strFirst & "_" & strLast & "_FS"
      file3.Copy strPath & fp & "\" & Name & file3.Ext
      Response.Write strPath & fp & "\" & Name & file3.Ext & "<br />" & vbCrLf
      file3.Delete
    end if
  next
end if
%>
0
 
jayhamAuthor Commented:
My host does not allow copy so I have to use copy virtual, and I am not allowed to dynamically create directories.  Is there anything you can do with the recent code I have provided
0
 
kiddangerCommented:
jayham...

Try changin the copy to copyvirtual, change the paths to virtual and remove the createDirectory lines, not to mention using the rights paths for your site and test this small script to see if it works.  It will be easier to debug than the other one.
0
 
jayhamAuthor Commented:
Ok now it seems to work, however if i just try files 1 and 3 i get an error

Microsoft VBScript runtime error '800a01a8'

Object required

/testing/borrower/businessPlan.asp, line 66
this is line 66
if file1.filename <> file2.filename then
0
 
kiddangerCommented:
Ok, I added some client-side validation so if the 2nd box is not filled in, the third box is not displayed.  If the 2nd box is filled and then the 3rd box is filled and then the 2nd box is emptied, then the third box is emptied and the third box disappears.

You need more validation but this is a start.  Also, we need to test on the server-side.
0
 
kiddangerCommented:
sorry, here are the changes I made to the input form.

I added a javascript script block:

<script type="text/javascript">
function showhide(thisid,thatid) {
  var master = document.getElementById(thisid);
  var slave = document.getElementById(thatid);
  if(master.value == "") {
    slave.value = "";
    slave.style.display = "none";
    } else {
    slave.style.display = "block";
    }
  }
</script>

and the following lines were updated:

<td><input id="fileTaxes1" name="fileTaxes" type="file" value="" onchange="showhide(this.id,'fileTaxes2')" /></td></tr>

<td><input style="display: none" id="fileTaxes2" name="fileTaxes2" type="file" /></td></tr>

You can test it here:
http://kiddanger.com/lab/test4.asp

I would also put an onsubmit on the form line so you could make sure other fields had content, etc.

I'll respond back after I look at the server-side.
0
 
kiddangerCommented:
You know, what this means is your original tests were not flawed.  You just didn't have validation and because of it, you were not testing to make sure fields had content.
0
 
kiddangerCommented:
Updated test4b.asp:

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True

dim upload, strPath, count
dim fileBusPlan, fileTaxes, file1, file2, file3, file
dim bp, fp, name

Set upload = Server.CreateObject("Persits.Upload.1")
strPath = "c:\domains\kiddanger.com\e"
count = upload.Save(strPath)

dim newId, strFirst, strLast
'newID=loanID
'strFirst=first
'strLast=last

bp = "\businessPlan"
fp = "\financialStatements"

set file1 = Upload.Files("fileBusplan")
set file2 = upload.files("fileTaxes")
set file3 = upload.files("fileTaxes2")

dim file1ok, file2ok, file3ok
file1ok = false : file2ok = false : file3ok = false
if typename(file1) = "IUploadFile" then file1ok = true
if typename(file2) = "IUploadFile" then file2ok = true
if typename(file3) = "IUploadFile" then file3ok = true

if count > 0 then
  for each file in upload.files
    if file.name = "fileBusplan" then
      'Response.Write file.name & "<br />" & vbCrLf
      Upload.CreateDirectory strPath & bp, True
      Name = newid & "_" & strFirst & "_" & strLast & "_busPlan"
      file1.Copy strPath & bp & "\" & Name & file1.Ext
      'Response.Write strPath & bp & "\" & Name & file1.Ext & "<br />" & vbCrLf
      if file1ok then
        file1.Delete
      end if
    end if
    if file.name = "fileTaxes" then
      'Response.Write file.name & "<br />" & vbCrLf
      Upload.CreateDirectory strPath & fp, True
      Name = newid & "_" & strFirst & "_" & strLast & "_FS"
      file2.Copy strPath & fp & "\" & Name & file2.Ext
      'Response.Write strPath & fp & "\" & Name & file2.Ext & "<br />" & vbCrLf
      if file2ok then
        if not file3ok or file1.filename <> file2.filename then
          file2.Delete
        end if
      end if
    end if
    if file.name = "fileTaxes2" then
      'Response.Write file.name & "<br />" & vbCrLf
      Upload.CreateDirectory strPath & fp, True
      Name = newid & "_" & strFirst & "_" & strLast & "_FS"
      file3.Copy strPath & fp & "\" & Name & file3.Ext
      'Response.Write strPath & fp & "\" & Name & file3.Ext & "<br />" & vbCrLf
      if file3ok then
        file3.Delete
      end if
    end if
  next
end if
%>

I had this done a lot sooner but got sidetracked to solve an issue that has been driving me crazy for a long time that just needed to be coded.
0
 
jayhamAuthor Commented:
Kiddanger you saved me again, I may call on you again if I run into any others probs
0
 
kiddangerCommented:
No problem.  I know you have to make changes to this code.  I would have put in some things you're requred to use like CopyVirtual but my data area is above my web root.  I was reading the ASPUpload manual and I saw there are quite a few security restrictions that can be set.  You might want to see if you can get a list of what's been set from your host.

Call on me anytime.  Sorry again for the delay in posting.  I write my ASP code in VS6 and I set my tabs to 2 spaces so when I post code here, it expands to 8 spaces since tabs are set to 8 and makes it very difficult to read.  So, I manually remove the tabs and add in 2 spaces.  I finally couldn't do that anymore so I wrote a routine that lets me browse my whole web site and select the file I want and do that for me, leaving it in a textarea with a button to copy it to the clipboard (IE) or just select it (NS/FF).  Then I can just paste it in here.  I tested it with the test4b.asp file update.  Anyway, not that problem is solved.
0
 
kiddangerCommented:
"Anyway, NOW that problem is solved."  Frustrating not to be able to edit posts.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 12
  • 11
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now