drupal image upload programmaticaly
The ability for file_get_contents() to fetch contents from an HTTP server depends on the allow_url_fopen parameter in php.ini

If it's not set, $image will be false and saving this leads to an empty file.

You may use Drupal's system_retrieve_file() instead. It's a wrapper on top of drupal_http_request() that comes with its own HTTP client implementation.

Example:

$file = system_retrieve_file('http://drupal.org/files/issues/druplicon_2.png',
                             'public://druplicon.png', false,  FILE_EXISTS_REPLACE);