Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 177
Product
FileUp
Version
3.x
Title
HOW TO: Create Unique Filenames
Problem

With SoftArtisans FileUp, versions 3.2.4 or newer, the optional "CreateNewFile" property allows you to automatically create a unique name if a file with the same name already exists in the upload directory on your server.


Solution

Using the CreateNewFile Property of SoftArtisans FileUp Versions 3.2.4 and Above
If you have the CreateNewFile property set to true, FileUp checks in the upload directory to see if a file of the same name has already been uploaded. If it has, FileUp takes the filename and concatenates a number - starting at _0 and going up to _999. So if your original filename is filename.ext and FileUp finds a file called filename.ext in the upload directory, it will rename the currently uploading file to filename_0.ext. Later, you upload another file by the same name and it is renamed to filename_1.ext, etc...

Important: Set CreateNewFile directly after setting FileUp's Path property.

Here is a sample of using the CreateNewFile property:

<%
'--- Instantiate SoftArtisans FileUp
Set upl = Server.CreateObject("SoftArtisans.FileUp")
'---
'--- Set the default path to store uploaded files.
upl.Path = "c:\temp"
'---
'--- Use CreateNewFile method
upl.CreateNewFile = true
'---
'--- Save file
upl.Save
%>

Created : 8/6/2003 11:35:03 AM (last modified : 8/6/2003 11:35:00 AM)
Rate this article!
Comments