I'm working on an http://example.com/userfiles/upload.php as a file browser for Drupal CKEditor and I want to restrict access to logged-in users but $user->uid inside upload.php doesn't seem to return any value.
I had to add the path /userfiles to Apache's rewrite rules exceptions to be able to access it (as otherwise, it forwards it to index.php?q= and doesn't load).
I don't fully understand yet how the index.php of Drupal works but I suspect that Apache's rewrite rules could be an issue in accessing the $user->uid value?
Or do I need additional code to access this value from Drupal?
$global user;
if (!$user->uid) {
echo("You're not allowed to upload files");
die(0);
}