create image file on server
<p>I'm trying to use the facebook api to get the app user's profile pic and then save it on the server. I'm getting the image just fine, but creating a new image file and saving it in the correct folder seems to be a problem. I tried using the fopen and file_put_contents functions, but apparently they require that a file be created before hand. How can I save the fb user's image on the server? My code is as follows.</p>

<pre><code>$facebook = new Facebook(array(
'appId' =&gt; '12345',
'secret' =&gt; '12345',
'cookie' =&gt; true
));

$access_token = $facebook-&gt;getAccessToken();

if($access_token != "") 
{
$user = $facebook-&gt;getUser();
if($user != 0)
{
            $user_profile = $facebook-&gt;api('/me');   

        $fb_id = $user_profile['id'];
        $fb_first_name = $user_profile['first_name'];
        $fb_last_name = $user_profile['last_name'];
        $fb_email = $user_profile['email'];

            $img = file_get_contents('https://graph.facebook.com/'.$fb_id.'/picture?type=large');
    $file = '/img/profile_pics/large/';
    rename($img, "".$file."".$img."");
    }
</code></pre>

<p>Any suggestions?</p>

<p>Thanks,</p>

<p>Lance</p>
