Solved

Security: The requested template has been denied access to D:\wwwroot.

Posted on 2011-09-21
8
333 Views
Last Modified: 2013-12-24
I am trying to create folders on a hosted website on the same level as the root. Testing internally I got this loop to work but I had all permissions.

On the hosted site I know I don't have permision for the level D:\wwwroot. I have permissions from our domain onwards which looks like this: D:\wwwroot\imailroom.ca.

How can I change the code below to start at our domain?
<cfset strCommonPath = "/" & "TestClient\iEnvelopes\" />  
<cfset strFileName = "testimage.jpg" />

<cfset strFilePath = "#expandPath('../../../')#imail_scans" />
<cfset DirectoryTree = Left(strFilePath, 2)>
<cfset strBareFilePath = "#replacenocase(strFilePath, DirectoryTree, "", 'all')#" />
<cfset strFullHostPath = strBareFilePath & replacenocase(strCommonPath, "/", "\", 'all') />
  
<!--- this creates folders if they do not exist on the web host site --->
<cfloop list="#strFullHostPath#" index="Directory" delimiters="\">
     <cfset DirectoryTree = ListAppend(DirectoryTree,Directory,"\")>

    <cfif DirectoryExists(DirectoryTree)> 
  <cfelse> 
     <cftry>
               <cfdirectory action="Create" directory="#DirectoryTree#"> 
          <cfcatch>
               <!--- Just let it loop --->
          </cfcatch>
     </cftry>
</cfif> 
</cfloop>

Open in new window

0
Comment
Question by:Shawn
  • 5
  • 3
8 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 36577964

The root folder can be referred to using:     expandPath('/')

I am not sure which variable you want to set to that, but that will get you the full path to your root.
0
 
LVL 1

Author Comment

by:Shawn
ID: 36581888
yep, using expandpath. just a little confused. Code is improving...Now I manage to create folders in the root but not quite the way I want.

In the example below I am creating both the folders TestClient and iEnvelopes but they are both being created at the root whereas iEnvelopes is actually a subfolder of TestClient.

any idea what I'm doing wrong here?
<cfset strCommonPath = "TestClient\iEnvelopes\" />  
<cfset strFileName = "testimage.jpg" />

<cfset strFilePath = "#expandPath('../../../')#imail_scans" />
<cfset DirectoryTree = Left(strFilePath, 2)>


<cfset strBareFilePath = "#replacenocase(strFilePath, DirectoryTree, "", 'all')#" />
<cfset strFullHostPath = strBareFilePath & replacenocase(strCommonPath, "/", "\", 'all') />
  
<!--- this creates folders if they do not exist on the web host site --->
<cfloop list="#strCommonPath#" index="Directory" delimiters="\">
     <cfset DirectoryTree = ListAppend(strFilePath,Directory,"\")>
 
     <cfif DirectoryExists(DirectoryTree)> 
     <cftry>
               <cfdirectory action="Create" directory="#DirectoryTree#"> 
          <cfcatch>
               <!--- Just let it loop --->
          </cfcatch>
     </cftry>
</cfif> 
</cfloop>

Open in new window

0
 
LVL 1

Author Comment

by:Shawn
ID: 36581903
oops, missign a line. see code below
<cfset strCommonPath = "TestClient\iEnvelopes\" />  
<cfset strFileName = "testimage.jpg" />

<cfset strFilePath = "#expandPath('../../../')#imail_scans" />
<cfset DirectoryTree = Left(strFilePath, 2)>


<cfset strBareFilePath = "#replacenocase(strFilePath, DirectoryTree, "", 'all')#" />
<cfset strFullHostPath = strBareFilePath & replacenocase(strCommonPath, "/", "\", 'all') />
  
<!--- this creates folders if they do not exist on the web host site --->
<cfloop list="#strCommonPath#" index="Directory" delimiters="\">
     <cfset DirectoryTree = ListAppend(strFilePath,Directory,"\")>
 
     <cfif DirectoryExists(DirectoryTree)>
     <cfelse> 
     <cftry>
               <cfdirectory action="Create" directory="#DirectoryTree#"> 
          <cfcatch>
               <!--- Just let it loop --->
          </cfcatch>
     </cftry>
</cfif> 
</cfloop>

Open in new window

0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 1

Author Comment

by:Shawn
ID: 36582355
got it to work with code below.
<cfset strCommonPath = "\" & "TestClient\iEnvelopes\" />  
<cfset strFileName = "testimage.jpg" />

<cfset strFilePath = "#expandPath('../../../')#imail_scans" />
<cfset DirectoryTree = strFilePath>


<cfset strBareFilePath = "#replacenocase(strFilePath, DirectoryTree, "", 'all')#" />
<cfset strFullHostPath = strBareFilePath & replacenocase(strCommonPath, "/", "\", 'all') />
  
<!--- this creates folders if they do not exist on the web host site --->
<cfloop list="#strCommonPath#" index="Directory" delimiters="\">
	 <cfset DirectoryTree = ListAppend(DirectoryTree,Directory,"\")>

     <cfif DirectoryExists(DirectoryTree)> 
     <cfelse> 
     <cftry>
               <cfdirectory action="Create" directory="#DirectoryTree#">
          <cfcatch>
               <!--- Just let it loop --->
          </cfcatch>
     </cftry>
</cfif> 
</cfloop>

Open in new window

0
 
LVL 39

Expert Comment

by:gdemaria
ID: 36582792
Your goal is just to create a directory if it doesn't exist?  given that the creation may involve multiple levels..

 did you ever try this?  I wonder if the command will create multiplevels at once?

<cfset pathToCreate = "testClient/iEnvelopes">
 
<cfset DirectoryTree = expandPath("/") & pathToCreate>
 <cfif NOT DirectoryExists(DirectoryTree)>
      <cfdirectory action="Create" directory="#DirectoryTree#">
 </cfif>
     

0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 36582798
If not, here's another version of the code you provided.  I'm having trouble following all the variables, but I think this is all you need... just loop through the relative path, adding the root directory, and create each one...


<cfset pathToCreate = "testClient/iEnvelopes">
<cfset rootDirectory = expandPath("/")>
 
<cfloop index="Directory"  list="#pathToCreate#"  delimiters="\/">
       <cfset DirectoryTree = ListAppend(rootDirectory,Directory,"\")>
     <cfif NOT DirectoryExists(DirectoryTree)>
        <cftry>
        <cfdirectory action="Create" directory="#DirectoryTree#">
         <cfcatch>
              <!--- Just let it loop --->
         </cfcatch>
         </cftry>
     </cfif>
</cfloop>

0
 
LVL 1

Author Comment

by:Shawn
ID: 36582841
>>I wonder if the command will create multiplevels at once?

I tried and it didn't work. found the loop in another ee solution.

just checking your other suggestion. It looks cleaner in any case
0
 
LVL 1

Author Closing Comment

by:Shawn
ID: 36583195
thx again gdemaria.

if you have seen the bug on Q_27322793 before feel free to jump in. agx and I are scratching our heads.
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question