Question: I am migrating my Facebook canvas application to using the new PHP SDK. However, I am having a problem getting the JavaScript SDK to work too.

I'm wanting to take advantage of methods such as `stream.publish` in the JavaScript SDK. Unfortunately I've not been able to get anything to work thus far. I have the following in the header of my application's `index.php` file:

```
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_GB/all.js"></script>
<script>
    FB.init({appId: *);
    FB.ui({
        method: 'stream.publish',
        message: 'Check out this great app!'
    });
</script>

```

My application ID has been removed for obvious reasons.

Where I'd expect the above to give the user a prompt to publish a message to their stream, it's not. Can I even use the new JavaScript SDK in Facebook canvas applications? Or is it reserved for iFrame applications and utilizing Facebook Connect on websites only?

Answer: 
Try `$path = '/images/imagename.jpg;` that way you're are referencing from the document root path.
You've almost got it.
path ought to be *absolute* (i.e. starting from `/`) from the web root.  

so, to check existence of the *file*, you have to extend it's path to absolute from the *filesystem root*.

```
$path = '/images/imagename.jpg';
if (file_exists($_SERVER['SERVER_NAME'].$path)) {
  echo "<img src=\"$path\">";
}

```

So, this would work for any part of the site and pass existence check.
Always stuck with absolute paths, it will never fail you.