Dynamic Folder Creation
Hi,
I have recently completed this bit of code and wanted to share it with you.
I have a property site that has images associated with each property and i wanted some code that created a folder on the server whilst creating a new record in the DB.
This is what I did :
<%
dim szValues
PropFolder = request.form("GetPropRef")
szValues = "'" & Request.Form("GetPropRef") &_
"', '"& Request.Form("GetDisplayRef") &_
"', '"& Replace(Request.Form("GetRightText"),"'","`") &_
"', '"& Replace(Request.Form("GetBottomText"),"'","`") &_
"', '"& Replace(Request.Form("GetText3"),"'","`") &_
"', '"& Request.Form("GetMainPictureURL") &_
"', '"& Request.Form("GetPicture1URL") &_
"', '"& Request.Form("GetPicture2URL") &_
"', '"& Request.Form("GetPicture3URL") &_
"', '"& Request.Form("GetActive") &_
"', '"& request.form("GetPropType") &_
"', '"& request.form("GetPrice") &_
"', '"& request.form("GetBeds") &_
"', '"& request.form("GetBaths") &_
"', '"& "No" &_
"'"
strsql = "INSERT INTO Properties ( PropertyRef, DisplayRef, RightText, BottomText, Text3, MainPictureURL, Picture1URL, Picture2URL, Picture3URL, Active, PropType, Price, Beds, Baths, Deleted ) VALUES(" &_
szValues & ")"
rsuser.open strsql,conn,1,2
'response.write szValues
%>
<%
'CreateFolder
Dim fso, fldr
Set fso = CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(Server.MapPath("../images/properties/" & PropFolder)) Then
response.redirect "newpropicons.asp?property=" & Request.Form("GetPropRef")
Else
Set fldr = fso.CreateFolder(Server.MapPath("../images/properties/" & PropFolder))
response.redirect "newpropicons.asp?property=" & Request.Form("GetPropRef")
End If
%>
__________________
Cheers,
C.
Chris Ellis
Icon-Business Ltd
www.icon-business.net
[email protected]
|