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

rename file before uploading usin SAfileUp

I'm using the SAfileUp object in order to allow to upload files to my server.
the method I'm using is SaveAs this way:

fileUp.FORM("file_link").SaveAs upload_path + fileName

everything works fine and the file is saved.
What I want is to check wether a file under that name is already exsits in this folder
if so I want to change the name of the new file and only then save it.
for example if I want to upload "thanks.jpg" and file by this name is already exists in my folder so
the new "thanks.jpg" will be renamed to "thanks1.jpg"

How can I do this? using saFileUp? using fso?
I don't have many points to give but I'll be greatful for any response

1 Solution
Yes you would use FSO to see if the file already exists.  Alternativly you could automatically save every uploaded file with a unique name made up of the userfilename and the date.  Depending on your needs of course.

IF you use FSO :

vFileName = [insertUserFileName]
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(upload_path & vFileName) then
 vFileName = month(date) & day(date) & year(date) & vFileName
end if
set fso = nothing

fileUp.FORM("file_link").SaveAs upload_path + vFileName


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now