Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-21
8
Medium Priority
?
353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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 2000 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

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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