Public:// doesn't work I am trying to code as follows:


  $uri='public://admin/myfile.txt';


but if (file_exists($uri)) fails

the complete path


  $uri='/var/www/html/www.mydomain.com/sites/default/files/admin/myfile.txt';


works and passes (file_exists($uri))

drupal_realpath('public://') returns /var/www/html/www.mydomain.com/sites/default/files

What am I missing here?
The path 'public://admin/myfile.txt' is not a real path (because of the 'public://'-part, which is a drupal-custom), it's a stream-wrapper-path (see link at end of answer).


  file_exists() can only process real-paths and registered stream-wrapper-paths


This means for you: Either your Drupal-installation didn't register it's custom stream-wrapper or your server-isp deactivated the stream-wrappers on your server/account.

You should check your php-config for Filesystem and Streams Configuration Options:
http://www.php.net/manual/en/filesystem.configuration.php

More info on php's stream-wrappers:
http://www.php.net/manual/en/wrappers.php

BTW: Registering of custom stream-wrappers is supported by PHP 4.3.2+