We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10374
    • 1 Posts
    If I store some documents (*.pdf) in the /assets/docs folder and restrict access to this files then I can still access to this files without any authentication from Modx if I know the full path.
    example: http://www.site.com/assets/docs/example.pdf

    Is there any way to restrict this type of access? Or can I store the documents in the database not in the file tree?

    thanks
    Gadesz
      • 23708
      • 35 Posts
      You can forbid access to this dir with an .htaccess file with the content "deny from all" so that a request to http://www.site.com/assets/docs/example.pdf will return a 403 error to the user.

      To control right access and download, you need a php script (called like this script.php?dowload=exemple.pdf) wich check the right of the current user and send file like this.
      header('Content-type: application/pdf');
      header('Content-Disposition: attachment; filename="exemple.pdf"');
      readfile('assets/docs/example.pdf');
        Native french speaker
        • 41045
        • 2 Posts
        there is ready solutions for modx? rolleyes