Hiding files from public access but viewable within domain

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robertybob
    New Member
    • Feb 2013
    • 116

    Hiding files from public access but viewable within domain

    Hi

    Not sure if this is the right place for this question so feel free to move it :)

    I am building a system in PHP whereby PDF/XML files are uploaded to a remote server. These files should not be able to be publicly viewed (imagine this is a CHMOD issue).

    However I need these files to show in an iframe or div within a PHP page on the same server.

    I know I can put the files behind the public_html folder which is great but then how do I get the page on the domain to show the file in the iframe/div?

    Thanks
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    However I need these files to show in an iframe or div within a PHP page on the same server.
    that statement doesn’t make sense (at least to me).

    for viewing something in a HTML page (an iframe ain’t different from that) you need a client. the client is always on another machine (with localhost being the sole exception) …

    Comment

    • meditation
      New Member
      • Jun 2014
      • 13

      #3
      Use .htaccess, give acces to local ip address, deny access from other IP address.

      Comment

      • robertybob
        New Member
        • Feb 2013
        • 116

        #4
        Thx for the replies and sorry for the late response.

        @Dormilich - I understand that an iframe etc is still an html page in itself and that is the source of the problem - ie, the page must be able to be read to be shown in the iframe but not be publicly accessible...

        @meditation - I'll give this a go and let you know shortly.

        All the best to you both

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          the page must be able to be read to be shown in the iframe but not be publicly accessible
          impossible. an iframe is nothing more than a browser window inside a browser window, so the same rules as a "regular" browser window apply regarding resources.

          another interpretation were that the data should be public, but not as a bare HTML page you could call. this calls for loading this content via AJAX i.e. you fetch the data (not the HTML representation of the data) from the server and make JS render/insert it into the current page. that could be an iframe, although that would be the most laborious way to render the data (since you need to create a complete page instead of just an HTML chunk)

          These files should not be able to be publicly viewed (imagine this is a CHMOD issue).
          why is that a CHMOD issue? one is about HTTP and the other about the filesystem.

          nevertheless, if the PDFs/XMLs are available in your page, I don’t see why it shouldn’t be possible to extract them from there (unless you don’t serve it as PDF/XML but as HTML representation thereof).
          Last edited by Dormilich; Jun 11 '14, 09:14 AM.

          Comment

          • robertybob
            New Member
            • Feb 2013
            • 116

            #6
            OK Thanks.

            Since no-one has suggested using the CHMOD on the folder containing the files I guess I'm looking at reading the PDF content into the page from a file location behind the public root.

            I'll see how I get on with that.

            @meditation - I think this would have worked but unfortunately the office does not have a static IP so is not feasible.

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              Since no-one has suggested using the CHMOD on the folder containing the files
              since CHMOD modifies the filesystem permission on the computer, it would make no difference who is accessing the resource from outside. it’s more like you either have access or not no matter who you are.

              I guess I'm looking at reading the PDF content into the page
              but you still need to tell the script whether the user viewing the page has the right to get that document served (e.g. via login).

              Comment

              • project manager
                New Member
                • Jun 2014
                • 10

                #8
                Copy the content in temporary file and show the temporary file, delete it after sometime.

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  that would still make it accessible from everywhere, though for a limited time.

                  Comment

                  Working...