7 Replies Latest reply on Feb 12, 2009 12:00 PM by naveenbalraj

    Browing documents outside wwwroot folder

    naveenbalraj
      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
        • 1. Re: Browing documents outside wwwroot folder
          Level 7
          "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

          • 2. Re: Browing documents outside wwwroot folder
            Level 7
            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/
            • 3. Re: Browing documents outside wwwroot folder
              TA-Selene Level 1
              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.
              • 4. Re: Browing documents outside wwwroot folder
                Level 7
                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/
                • 5. Re: Browing documents outside wwwroot folder
                  TA-Selene Level 1
                  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.

                  • 6. Re: Browing documents outside wwwroot folder
                    Level 7
                    now that i re-read the OP's question, i see your point!

                    Azadi Saryev
                    Sabai-dee.com
                    http://www.sabai-dee.com/
                    • 7. Re: Browing documents outside wwwroot folder
                      naveenbalraj Level 1
                      Thanks guys, for your quickest reponses. I did follow Azadi's suggestion and it just worked fine.

                      -Naveen