PHP/File Directory/realpath
Cleaning up a file name with realpath()
<source lang="html4strict">
$filename = realpath("/usr/local/data/$_POST[user]"); if ("/usr/local/data/" == substr($filename, 0, 16)) {
print "User profile for " . htmlentities($_POST["user"]) .":
"; print file_get_contents($filename);
} else {
print "Invalid user entered.";
}
</source>
realpath.php
<source lang="html4strict">
<?php
$imgPath = "../cover.gif"; $absolutePath = realpath($imgPath); echo $absolutePath;
?>
</source>