Cleaning up a file name with realpath() : realpath « File Directory « PHP






Cleaning up a file name with realpath()

 
$filename = realpath("/usr/local/data/$_POST[user]");

if ('/usr/local/data/' == substr($filename, 0, 16)) {
    print 'User profile for ' . htmlentities($_POST['user']) .': <br/>';
    print file_get_contents($filename);
} else {
    print "Invalid user entered.";
}
  
  








Related examples in the same category

1.realpath.php