Print Page | Close Window

Rename uploaded images/files

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums Modifications
Forum Description: Mod's and Add-on's for Web Wiz Forums.
URL: https://forums.webwiz.net/forum_posts.asp?TID=28667
Printed Date: 28 March 2026 at 10:35pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Rename uploaded images/files
Posted By: klr3
Subject: Rename uploaded images/files
Date Posted: 23 June 2010 at 9:37pm
Hi!
 
I would like to rename uploaded files to a unique filename (based on date/time), but can´t seem to figure out how to.
 
I use following components: Persits AspUpload 3 and AspJpeg (AspJpeg i just for image resize..)
 
I have looked in to "/functions/functions_upload.asp", but with no luck Cry
 
The filename should be something like this:
 

Dim ImageDate
Dim MyNewFileName
ImageDate = Year(Now()) & "" & Month(Now()) & "" & Day(Now()) & "" & Hour(Now()) & "" & Minute(Now())& "" & Second(Now())
MyNewFileName = "websitename_"& ImageDate
 
Could anyone guide me or help with some code?
Thanks!



Replies:
Posted By: klr3
Date Posted: 25 June 2010 at 1:43pm
Found at solution my self, but it´s limited to images alone:
 

'Filter file name to remove anything that isn't allowed by the filters
 
strNewFileName = formatFileName(strNewFileName)
 
'If this is an iamge
If strUploadType = "image" Then
 
'Declare new variables
 
'Imagename based on date/time
Dim ImageDate
Dim MyNewFileName
 
'Get extension (only .gif, .jpg, .png)
Dim MyNewFileExt
ImageDate = Year(Now()) & "" & Month(Now()) & "" & Day(Now()) & "" & Hour(Now()) & "" & Minute(Now())& "" & Second(Now())
MyNewFileName = "my_prefix_here"& ImageDate
MyNewFileExt = Mid(strNewFileName, InStrRev(strNewFileName, "."), 4)
 
strNewFileName = MyNewFileName & MyNewFileExt
End if
 
Imagenames ends up with a name like this example:
"my_prefix_here_2010625144219.jpg"
 
If you have any comments, please let me know Wink



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net