Print Page | Close Window

File Upload renaming

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=19762
Printed Date: 11 April 2026 at 2:47pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: File Upload renaming
Posted By: jckruger
Subject: File Upload renaming
Date Posted: 08 May 2006 at 10:39am
I have just been queried about the file upload option by one of my forum members.
 
As part of their file version control they would like to see the file name as they uploaded it if possible and not to have the file ammended with the date and time at the start. Obviously I would tell them to keep the file name to a minimum as the preview window truncates the file name for viewing space.
 
Where might the part be that renames the file with the date and time.
 
Thanks in advance
 
Justin



Replies:
Posted By: WebWiz-Bruce
Date Posted: 09 May 2006 at 9:06am
You could change it in the functions_upload.asp file, but be warned if you remove the date/time part, your forum upload function will probably become unstable and you will have issues with files of the same name.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jckruger
Date Posted: 31 May 2006 at 7:19am

Hi All,

Where might the code be that moves the file from the Temp directory into the uploads directory?. I am going to try some code that will delete the file in the uploads directory before the file is moved as it currently will not move the file if the same filename exists. I have removed the additional date part and have found in functions_Upload.asp
 
'Save the file to disk
.Files(1).SaveAs strFileUploadPath & "/" & strNewFileName
 
does overwrite the original. That is perfect.
 
What I now need it to do is then delete the file in the uploads directory before moving the file from the temp directory. I only want this to happen when someone is editing a post and pressing "Update Post" or Post New Topic in a new topic. I don't want it to delete the file until these buttons are pressed like it is done now with the temp directory.
 
This is so the person uploading can overwrite a file and not have to change any other references in other topics.
 
Can someone give me a general idea where to look.
 
I was thinking just to use: or somethink like it
 
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(YOUR_FILE)

I just need to know where
 
Cheers
 
Justin


Posted By: WebWiz-Bruce
Date Posted: 31 May 2006 at 3:24pm
Files are moved from the temp directory in the files, new_posts.asp and edit_post.asp

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jckruger
Date Posted: 01 June 2006 at 1:19am
I tried editing both those files with this:
 
--------------------------------------------------------%>--------------------------------
'See if file exsists
  If objFSO.FileExists(Server.MapPath(strUploadFilePath & "\temp\" & saryFileUploads(intLoop))) Then
   
      'Delete file in uploads before moving new one from Temp directory
   objFSO.DeleteFile Server.MapPath(strUploadFilePath & "\" & saryFileUploads(intLoop))

  
   'Move file
   objFSO.MoveFile Server.MapPath(strUploadFilePath & "\temp\" & saryFileUploads(intLoop)), Server.MapPath(strUploadFilePath & "\" & saryFileUploads(intLoop))
--------------------------------------------------------%>--------------------------------
 
I also edited functions_upload.asp with this:
 
--------------------------------------------------------%>--------------------------------
'If the file is OK save it to disk
    If lngErrorFileSize = 0 AND blnExtensionOK Then
    '### DISABLED TO KEEP FILENAME THE SAME ### 
     'Create a new file name for the file with the date a time included
     'strNewFileName = newFileName(strNewFileName) ' commented out
     
     'Save the file to disk
     .Files(1).SaveAs strFileUploadPath & "/" & strNewFileName
--------------------------------------------------------%>--------------------------------
 
and it seems to work OK in my lab. The original file is deleted just befote the file is moved from the temp directory.
 
What I was having trouble with was that the objFSO.MoveFile was not moving the file if the same name file existed so I delete the file with objFSO.DeleteFile function in the uploads folder (not the "temp" folder) just before the file move function.
 
Feedback welcome.
 
Cheers Justin



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