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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
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
  • 1
  • 2
//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');
    New question is currently disabled!