My PHP script uses $_POST['fileUrl']; to retrieve a file for the user, which I believe poses a security threat because anyone could append "../../" etc to the fileUrl to gain access to other files on my server.
I need to find the best (most secure) way to limit files my script can access to a specific directory. From what I've read setting the open_basedir flag will limit my script's access to the path specified.
script.php
$fileUrl = $_POST['fileUrl'];
$content = chunk_split(base64_encode(file_get_contents($fileUrl)));
.htaccess
php_flag open_basedir "var/www/vhosts/mydomain.com/php_can_only_access_files_in_this_directory/"
Is there a better way to do this? Is this script completely secure from accessing folders outside the open_basedir?