Access files outside of web root

Coldfusion script to call files outside of web root?

Page 1 of 1

8 Replies - 5650 Views - Last Post: 27 April 2009 - 09:01 AM Rate Topic: -----

#1 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Access files outside of web root

Post icon  Posted 17 April 2009 - 09:34 AM

Hello and thanks for your time. I am using fusebox to create a coldfusion application. I have been asked to move certain files outside (above) the web root so they are not accessible via the web browser. I can no longer directly link to them, which is the point.

Is there a coldfusion script that can do this? I still want to get to them, but considering where they are now residing I do not know how to do that. If anyone can point me in the right direction, that would be wonderful! Not looking for any code at this point, just some direction. Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: Access files outside of web root

#2 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Access files outside of web root

Posted 17 April 2009 - 10:28 AM

Look into using cfcontent. It is often used to serve up documents from a protected area.
Was This Post Helpful? 0
  • +
  • -

#3 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Re: Access files outside of web root

Posted 20 April 2009 - 08:38 AM

View Postsansclue, on 17 Apr, 2009 - 09:28 AM, said:

Look into using cfcontent. It is often used to serve up documents from a protected area.


Sansclue,
Thanks for the info. I have researched and implemented cfcontent. I have placed all sensitive documents above the web root and then created an actionpage to target them in their new location.

I'm using fusebox to create this app. Not sure if you are familiar with it. Actions are basically targeted using the url

<a href="https://xxx.xx.xxx.xxx/index.cfm?fuseaction=catControl.getFile" target="_blank">



getFile then has a fuseaction that points to a coldfusion action page (a fuse) that does the work. It's an interesting way to create an app.

I'm trying to pass variables in the query string, but it does not seem to like it. Here's what I am doing...

< a href="https://xxx.xx.xxx.xxx/index.cfm?fuseaction=catControl.getFile & data=#filePath#" target="_blank">



On the other end, the actionpage when processed give me an error that filePath is undefined. I ran a cfdump on the page that has the above link and the filePath returns a positive path to the file.

Am I appending the url properly to pass the variable? I've tried several combinations but I cannot seem to get it right. Thanks for any help you may be able to provide.

Cheers!
Was This Post Helpful? 0
  • +
  • -

#4 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Re: Access files outside of web root

Posted 20 April 2009 - 09:47 AM

Quote

On the other end, the actionpage when processed give me an error that filePath is undefined. I ran a cfdump on the page that has the above link and the filePath returns a positive path to the file.

Am I appending the url properly to pass the variable? I've tried several combinations but I cannot seem to get it right. Thanks for any help you may be able to provide.


OK, on the action page when I reference the passed variable I am successfully using #URL.data# instead of just #data# and it seems to work fine. In other situations I have used the latter and it has worked fine. Perhaps this has something to do with the fact that I am using Fusebox to build this app.

Cheers!!
Was This Post Helpful? 0
  • +
  • -

#5 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Access files outside of web root

Posted 20 April 2009 - 03:49 PM

View Postmidasxl, on 20 Apr, 2009 - 08:47 AM, said:

index.cfm?fuseaction=catControl.getFile & data=#filePath#" ...


No, it just has the wrong parameter name. The syntax is:

paramterName=parameterValue

So if want it to be called "filePath", use that name instead of "data".

... &filePath=#filePath#"...>

This post has been edited by sansclue: 20 April 2009 - 03:50 PM

Was This Post Helpful? 0
  • +
  • -

#6 Art_web  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-April 09

Re: Access files outside of web root

Posted 21 April 2009 - 10:48 AM

sorry, cant help...

:blink:
Was This Post Helpful? 0
  • +
  • -

#7 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Re: Access files outside of web root

Posted 22 April 2009 - 06:17 AM

View Postsansclue, on 20 Apr, 2009 - 02:49 PM, said:

View Postmidasxl, on 20 Apr, 2009 - 08:47 AM, said:

index.cfm?fuseaction=catControl.getFile & data=#filePath#" ...


No, it just has the wrong parameter name. The syntax is:

paramterName=parameterValue

So if want it to be called "filePath", use that name instead of "data".

... &filePath=#filePath#"...>


Sansclue, thanks again. I was giving you the wrong information. This is how I have the URL...
index.cfm?fuseaction=catControl.getFile & data=#filePath#"



So I tried referencing #data# in the action page. This does not work unless I use #URL.data#
Was This Post Helpful? 0
  • +
  • -

#8 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Access files outside of web root

Posted 22 April 2009 - 06:57 AM

View Postmidasxl, on 22 Apr, 2009 - 05:17 AM, said:

So I tried referencing #data# in the action page. This does not work unless I use #URL.data#


Then use #url.data# ;-) It is the correct and it is better to scope your variables like that anyway. ie Use #scopename.variablename# instead of just #variablename#.
Was This Post Helpful? 0
  • +
  • -

#9 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Re: Access files outside of web root

Posted 27 April 2009 - 09:01 AM

Thanks Sansclue. Here's what I ended up doing...

Here's a URL example
<a href="index.cfm?fuseaction=catModel.getFile & file='share/local/name_of_file.txt'"



Then fusebox would map to the appropriate action page which is the following...
<!---This will extract the right 3 characters from the variable #URL.file#, thus getting the file extension--->
<cfset type = Right(#URL.file#,3)>

<cfswitch expression = "#type#">
	 <cfcase value="txt">
		  <cfcontent type="text/plain"
		  file="#request.fileArea##URL.file#"
		  deletefile="no">
	 </cfcase>
	 <cfcase value="doc">
		  <cfcontent type="application/msword"
		  file="#request.fileArea##URL.file#"
		  deletefile="no">
	 </cfcase>

etc, etc. for more mime types
</cfswitch>



This works great!

Cheers!

This post has been edited by midasxl: 27 April 2009 - 09:05 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1