Rename based on Recordset value ASP
Unique filenames with recordset values!
Question:
How can I rename uploaded files using one or more recordset values?
Answer:
When users have the option to upload their own images to a website, it might be usefull to rename these images to include user data in the filename. When creating the mask to rename a file, a few simple rules have to be seen to.
All text that you want to enter in the filename should be between ". Values from the original filename should be between ##. Use the & sign to connect text and recordset code.
In the example below, two fields from a recordset were used to rename the file:
sip1.Mask = rsUser.Fields.Item("User_Name").Value&"_"& rsUser.Fields.Item("UserID").Value&"_##name##.##ext##"
Note: The code for your recordset should be ABOVE the SIP code to prevent errors from appearing!
Note: Using this way to rename filenames, any information from any recordset can be used!
Comments
Be the first to write a comment
You must me logged in to write a comment.