Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file save question???

Status
Not open for further replies.

anyideas

Programmer
May 2, 2002
127
GB
Hi

I don't konw if anyone can help.

I trying to save a file to a folder during an upload. I check to see if a file with the same details exists (done that bit) and if not I want to save the file.

This is where I'm stuck.

The code i'm using I've posted below.

Any help really appriciated..

<%

FullPath=Request(&quot;file1&quot;)
SplitPath=Split(FullPath,&quot;\&quot;)
FileName=Ubound(SplitPath)
FileName=SplitPath(FileName)
ExtensionSplit=Split(FileName,&quot;.&quot;)
Extension=Ubound(ExtensionSplit)
Extension=ExtensionSplit(Extension)

Dim FileNamePath

FileNamePath=&quot;C:\Inetpub\
Set FileSys = CreateObject(&quot;Scripting.FileSystemObject&quot;)

If FileSys.FileExists(FileNamePath) then
Response.Write(&quot;<script>alert('File Already Exists')
</script>&quot;)

else
'Do file save
end if
%>
 
I don't quite understand what you're trying to do, but by the looks of it, this will do:

object.Copy destination[, overwrite]
 
Sorry Pyramus, What I'm trying to do is

If File Exists Then
msg-sorry file already exists
else
save to file trying to be uploaded
End if

Tried your code but got back error:
Cannot use parentheses when calling a Sub

code below:

If FileSys.FileExists(FileNamePath&FileName) then
Response.Write(&quot;<script>alert('Sorry - File Already Exists')</script>&quot;)
else
'Do file save
FileSys.CopyFile(FullPath,FileNamePath&FileName, overwrite)
end if

thanks for trying
 
Thanks Jon

Finally have the upload working the way I want it!
 
FWIW, you may want to consider making this into a FAQ in the ASP forum, because this question arises rather frequently. Jon Hawkins
 
This has now been made into a FAQ!!

Again many thanks to Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top