Pure ASP Upload 3 Support Product Page

Solved

Use Form Variable for Dynamic Folder

Reported 24 Jan 2014 07:15:04
1
has this problem
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:

Dim strUploadFolder
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:

Dim strContentSubFolder
	strContentSubFolder = (rs_content__MMColParam)


Add the string variable to the form action:

<%=MM_editAction%>&Content_SubFolder=<%=strContentSubFolder%>


And that's all there is to it!

Replies

Replied 27 Feb 2014 18:41:55
27 Feb 2014 18:41:55 Christine T replied:
This is awesome, thank you! Sorry for my ignorance, but if I wanted to add a "word" or another string before the subfolder's dynamic name, where in the script would I do that? Can't seem to get the syntax right. For instance:

Dim strContentSubFolder
strContentSubFolder = "word" & (rs_content__MMColParam)
Replied 28 Feb 2014 01:13:53
28 Feb 2014 01:13:53 James Threadgill replied:
Try
strContentSubFolder = """word""" &  (rs_content__MMColParam)

Or
<%=MM_editAction%>&Content_SubFolder=Word<%=strContentSubFolder%>


Or you can try:
strContentSubFolder = ("word")

And then (this isn't displaying correctly in code)

strContentSubFolder = strContentSubFolder & (rs_content__MMColParam)
Replied 28 Feb 2014 18:42:29
28 Feb 2014 18:42:29 Christine T replied:
I've realized my error in thinking and what I'm trying to accomplish. The output for the subfolder name is already a "word". I want the output to be that word and its value. This worked:

strContentSubFolder = (rs_content__MMColParam) & Request.Querystring( "id" )

However, I now realize this creates other issues I must decide how to deal with! Thanks for your help.

Reply to this topic