24 Jan 2014 07:15:04 James Threadgill posted:
I recently worked on a script that uses a database generated or stored value as the upload folder for uploaded files. The files are uploaded to a single folder /content_images/. Within the /content_images/ folder each content item gets a subfolder designated with the item database ID so that when the content is deleted all the associated images are deleted as well, a traditional server resource management technique.
Initially I tried using a form variable to hold the folder/subfolder designation but my images ended up in the /content_images/ root folder rather than the subfolder designated. I got online with my good friend Miro of the DMX Zone technical support team and we tried several methods of passing the form variable, all of which failed. Then I hit upon the idea of adding the subfolder designation to the form action querystring. Success! Without further introduction, here is the code.
Place this snippet in on the page above the Pure ASP Upload behavior. It should be the first code below the includes:
strUploadFolder = "../content_images/" & Request.QueryString("Content_SubFolder") & ""
Modify the Pure ASP Upload behavior like so, (or place the code in the Pure ASP Upload extension interface.
pau.UploadFolder = """" & strUploadFolder & """"
Assign the folder designation to a string variable:
strContentSubFolder = (rs_content__MMColParam)
Add the string variable to the form action:
And that's all there is to it!