I got this script where i upload a file using sa. everything works perfect excpet i cant get it to check if a file exists and if it does then give it a unique name. this code (depending on how its mix-matched) produces 3 kinds of output. either the filename stays and its always overwritten, the rand works but it only will save the tmp file, or the random works only and save the rand gen filename even if it doesnt exist and it wont show the file name on the next page. anyone got any ideas? maybe even if i could just get it to tak a number on each file instead of checking if it exists would suffice. here is code:
YOU CAN SEE WHERE I COMMENTED OUT A FEW PLACES SO I CAN MIX-MATCH CODE
<% Dim upl %>
<% Set upl = Server.CreateObject("SoftArtisans.FileUp") %>
<%Dim upf%>
<% Set upf = CreateObject("SoftArtisans.FileManager") %>
<% upl.Path = "C:\WUtemp" %>
<% if upl.IsEmpty Then %>
<% Else %>
<%
Dim numberr
Dim strNameWOext
Dim strOname
strOname = upl.form("f1").Shortfilename
Dim y
Dim strExt
%>
<% If upf.FileExists(strOname) Then
'--- Generate a random number to append to the filename
Randomize
numberr = cStr(Rnd())
'--- Separate filename from filename extension
y = InStr(strOName,".")
strNameWOext = Left(stroName,y-1)
y = Len(strOName) - y
strExt = Right(strOName,y)
'--- Call SaveAs so a new name can be provided
upl.Form("f1").SaveAs strNameWOext & "_" & _
numberr & "." & strExt
Else
'--- Calling Save preserves original file name
upl.save
Dim fileup
fileup = upl.form("f1").servername
End If
End If %>
<% 'upl.Save %><BR>
<br><br>
<%
'Dim Fileup
'Fileup = upl.Form("f1").ServerName
%>
<% 'end if %>
YOU CAN SEE WHERE I COMMENTED OUT A FEW PLACES SO I CAN MIX-MATCH CODE
<% Dim upl %>
<% Set upl = Server.CreateObject("SoftArtisans.FileUp") %>
<%Dim upf%>
<% Set upf = CreateObject("SoftArtisans.FileManager") %>
<% upl.Path = "C:\WUtemp" %>
<% if upl.IsEmpty Then %>
<% Else %>
<%
Dim numberr
Dim strNameWOext
Dim strOname
strOname = upl.form("f1").Shortfilename
Dim y
Dim strExt
%>
<% If upf.FileExists(strOname) Then
'--- Generate a random number to append to the filename
Randomize
numberr = cStr(Rnd())
'--- Separate filename from filename extension
y = InStr(strOName,".")
strNameWOext = Left(stroName,y-1)
y = Len(strOName) - y
strExt = Right(strOName,y)
'--- Call SaveAs so a new name can be provided
upl.Form("f1").SaveAs strNameWOext & "_" & _
numberr & "." & strExt
Else
'--- Calling Save preserves original file name
upl.save
Dim fileup
fileup = upl.form("f1").servername
End If
End If %>
<% 'upl.Save %><BR>
<br><br>
<%
'Dim Fileup
'Fileup = upl.Form("f1").ServerName
%>
<% 'end if %>