• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Browing documents outside wwwroot folder

Guest
Feb 12, 2009 Feb 12, 2009

Copy link to clipboard

Copied

Hi All,

I have a situation, where I need to access something outside wwwroot folder. Meaning, I have created a folder 'uploads' outside wwwroot, and have documents in that. Now I need to browse those document when inside the application. For example, http://sample.com/index.cfm. Now, when I'm in this page. I need to access the document, outside wwwroot. How can I browse this.

More detailed explanation:

folder sturcture:
Uploads
wwwroot>sample>index.cfm

I'm in the page sample.com/index.cfm. I have a link <a href="">Document to browse</a> in index.cfm.
Question: what do I provide, in href, to access the document inside Uploads folder.

Hope this makes sense.

Thanks for any help.
-Naveen
TOPICS
Advanced techniques

Views

979

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 12, 2009 Feb 12, 2009

Copy link to clipboard

Copied

"naveenbalraj" <webforumsuser@macromedia.com> wrote in message news:gn1juu$t2a$1@forums.macromedia.com...
> Hi All,
>
> I have a situation, where I need to access something outside wwwroot folder.
> Meaning, I have created a folder 'uploads' outside wwwroot, and have documents
> in that. Now I need to browse those document when inside the application. For
> example, I'm in this page, http://sample.com/index.cfm. Now, when the user is
> on this page. I need to access the document, outside wwwroot. How can I browse
> this.
>
> More detailed explanation:
>
> folder sturcture:
> Uploads
> wwwroot>sample>index.cfm
>
> I'm in the page sample.com/index.cfm. I have a link <a href="">Document to
> browse</a> in index.cfm.
> Question: what do I provide, in href, to access the document inside Uploads
> folder.
>
> Hope this makes sense.
>
> Thanks for any help.
> -Naveen
>

Something like this?


<cfdirectory action="list" filter="*.doc" directory="C:\Uploads" name="myFiles" sort="Name">

<cfoutput query="myFiles">
<a href="#Name#">#Name#</a><br />
</cfoutput>


--
Ken Ford
Adobe Community Expert - Dreamweaver/ColdFusion
Adobe Certified Expert - Dreamweaver CS3
Adobe Certified Expert - ColdFusion 8
Fordwebs, LLC
http://www.fordwebs.com
http://www.cfnoob.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 12, 2009 Feb 12, 2009

Copy link to clipboard

Copied

it does make sense.

what you need is an interim cf page which you call in your link and pass
some document identifier (i.e name, or id assigned to it in the db) so
it knows which document to fetch. then you use a combination of
<cfheader> and <cfcontent> tags to serve up your document - these forums
have a sample of that code for pretty much all document types, just search.

basically, your link will look something like
<a href="savedoc.cfm?doc=My_Secret_File.pdf">click here</a>

and your savedoc.cfm page will use the var you passed to it in the url
scope to get the doc from the folder outside of webroot and serve it up
to the user either as attachment (will ask user to save file) or inline
(will open in default application for that doc type).

you can do lots of things like that. useful for images and media files,
too. this link also may be helpful:

http://www.adobe.com/go/kb405330

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 12, 2009 Feb 12, 2009

Copy link to clipboard

Copied

Can you create a virtual directory on your web server? That's what I do. Then you just reference the name of the virtual directory, and it will point to your directory no matter where it is on the server.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 12, 2009 Feb 12, 2009

Copy link to clipboard

Copied

TA-Selene,

the whole point of having files outside of web root is to make them NOT
web-accessible, so nobody can just type the url to the file or browse to
it, but can only get to it in a controlled manner via the infrastructure
you provide in your application.

some usual reasons for putting files outside of web root are security
(to restrict access to them to authorized users of your application
only), or access logging/stats (to ensure accuracy of data)

all files in a virtual dir are web-accessible by default, so that
defeats the purpose of having the file off webroot.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 12, 2009 Feb 12, 2009

Copy link to clipboard

Copied

Azadi,

Thank you for the remedial explanation of web folder setup. I am quite aware of how and why you would not want documents available from within the web root and have done this many times myself by creating an intermediary page - as you suggested - with much success, for both documents and images.

The question wasn't so clear that he did indeed need those restrictions, so I offered up what seemed an obvious mention, in case it was something he overlooked, as can happen. Sometimes the most obvious answer is what is needed. That was not the case here, but it never hurts to throw it out there.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 12, 2009 Feb 12, 2009

Copy link to clipboard

Copied

now that i re-read the OP's question, i see your point!

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 12, 2009 Feb 12, 2009

Copy link to clipboard

Copied

LATEST
Thanks guys, for your quickest reponses. I did follow Azadi's suggestion and it just worked fine.

-Naveen

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation