This content has been marked as final. Show 7 replies
"naveenbalraj" <firstname.lastname@example.org> wrote in message news:email@example.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
> More detailed explanation:
> folder sturcture:
> 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
> Hope this makes sense.
> Thanks for any help.
Something like this?
<cfdirectory action="list" filter="*.doc" directory="C:\Uploads" name="myFiles" sort="Name">
<a href="#Name#">#Name#</a><br />
Adobe Community Expert - Dreamweaver/ColdFusion
Adobe Certified Expert - Dreamweaver CS3
Adobe Certified Expert - ColdFusion 8
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:
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.
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.
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.
Thanks guys, for your quickest reponses. I did follow Azadi's suggestion and it just worked fine.