Lets say I want to build a simple PHP script that let me access files inside a folder:
$path = $_GET['path'];
$path = str_replace('..', '', $path);
$path = "./static/" . $path;
readfile($path);
Is the line 2 on this example enough to avoid people reading files outside the 'static' folder?
..
is perfectly allowed to be part of a filename (soa..txt
is OK). Your code breaks on legitimate filenames.