Search code examples
phpxmlresourcesloadlocal

Need assistance with "Not allowed to load local resource" issue


I'm trying to use an xml sheet for a project in php but I can't grab the values - because of some security thing I guess.

The chrome console gives me this issue:

'Not allowed to load local resource: file:///usr/share/nmap/nmap.xsl'

I'm wondering if I have to change some config file settings, or execute some command.

I assume it has something to do with security in accessing local files on a webserver. (There's very little help online about this!)

I'm hosting on a RiPi (raspbian). I've tried chmod & chown on the folders and files.


Solution

  • The webserver is captured inside it's document root. That is not the server root directory but the "document root" set in the webserver configuration. There is no way to break out.

    To the webserver, the path / is not the root directory of the server but the document root directory.

    You are trying to access a file outside that webserver root directory.


    I'd create a Symlink inside the document root (e.g. /var/www/xml_files) that points to /usr/share/nmap

    ln -s /usr/share/nmap /var/www/xml_files
    

    Don't forget to set Options +FollowSymlinks inside the apache site-configuration, otherwise it won't work.