Web Wiz - Green Windows Web Hosting - Celebrating 25 Years!

  New Posts New Posts RSS Feed - File Upload renaming
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

File Upload renaming

 Post Reply Post Reply
Author
jckruger View Drop Down
Groupie
Groupie
Avatar

Joined: 18 April 2006
Location: Australia
Status: Offline
Points: 135
Post Options Post Options   Thanks (0) Thanks(0)   Quote jckruger Quote  Post ReplyReply Direct Link To This Post Topic: File Upload renaming
    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
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
jckruger View Drop Down
Groupie
Groupie
Avatar

Joined: 18 April 2006
Location: Australia
Status: Offline
Points: 135
Post Options Post Options   Thanks (0) Thanks(0)   Quote jckruger Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 31 May 2006 at 3:24pm
Files are moved from the temp directory in the files, new_posts.asp and edit_post.asp
Back to Top
jckruger View Drop Down
Groupie
Groupie
Avatar

Joined: 18 April 2006
Location: Australia
Status: Offline
Points: 135
Post Options Post Options   Thanks (0) Thanks(0)   Quote jckruger Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.