An authenticated user can access the page (download.php), where he can view files in tempFiles
Set .htaccess to "deny from all" in tempFiles so that no one can directly access, and then in the download.php file, each file must be uploaded using a token, which is sad Ashish Awasthi
If you don't like tokens, can you do something like download? file = iGuessedIt012345.csv, but if you do so, use the regex in the white list to see if everything is correct!
Example:
$var="iGuessedIt012345.csv";
if (preg_match('#^[[:alnum:]]+\.csv$#i', $var)){
echo "ok";
}else{
echo "bad request";
}
example2:
$var="iGuessed_It-012345.csv";
if (preg_match('#^[a-zA-Z0-9\-\_]+\.csv$#i', $var)){
echo "ok";
}else{
echo "bad request";
}
source
share