Are you absolutely sure your filenames are going in properly?
I'm not familiar with the syntax you are using.
May not be your issue, btu have you tried it as:
if (file_exists($imgdir . $subsec . $picid . ".jpg")) {blah blah anchor code blah blah}
No, I definately did a hello world of the string I used and it outputted the correct URL. I either need to find a new webhost (which I did:
http://www.frihost.net) or hardwire the image into the web page code so that the image data is sent to the user with the web page and it therefore doesn't have to be accessed by the user.