Grab Picture From Remote URL

It’s a really easy function to that copies remote picture into local folder. You can just use PHP copy() directly, but this function does little more than that, enjoy.
PHP
1234567891011
function grab_remote_pic($new_file_name, $local_dir_path, $remote_picture_url)
{
	if(!is_dir($local_dir_path)){ //create new dir if doesn't exist
		mkdir($local_dir_path);
	}
	$local_file_path = $local_dir_path .'/'.$new_file_name;
	if(copy($remote_picture_url, $local_file_path))
	{
		return true;
	}
}
Usage :
PHP
12
//grab_remote_pic(NEW FILE NAME, LOCAL SAVE PATH, REMOTE IMAGE URL)
grab_remote_pic('new_file_name.gif', 'home/path/to/local/images/', 'http://graph.facebook.com/1442161041/picture?width=120&height=120');