How to upload enterprise blog picture programatically in drupal 7
Ok, here is my testing example. I can't say that it works perfectly but in my case it works fine. And, of course, you can modify/customize it by your needs if you want (add validation, check file path, directories, and so on..):

function _executeFile($uri, $uid) {

  $file_url = file_create_url($uri);
  $file = system_retrieve_file($file_url, NULL, TRUE, FILE_EXISTS_REPLACE);

  if ($file) {
    $user = user_load($uid);
    $file = file_load($file-&gt;fid);
    $file-&gt;status = FILE_STATUS_PERMANENT;
    file_save($file);

    // file_usage_add($file, 'MY_MODULE', 'enterprize_picture', $file-&gt;fid);

    $file_info = image_get_info($file-&gt;uri);

    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['fid'] = $file-&gt;fid;
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['alt'] = '';
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['title'] = '';
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['width'] = $file_info['width'];
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['height'] = $file_info['height'];
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['uid'] = $file-&gt;uid;
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['filename'] = $file-&gt;filename;
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['uri'] = $file-&gt;uri;
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['filemime'] = $file-&gt;filemime;
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['filesize'] = $file-&gt;filesize;
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['status'] = '1';
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['timestamp'] = $file-&gt;timestamp;
    $user-&gt;field_enterprise_blog_picture[LANGUAGE_NONE][0]['rdf_mapping'] = array();

    user_save($user);
  }
  else {
    // SET VALIDATION ERROR
  }
}


and call it like this:

define('DRUPAL_ROOT', getcwd());
require_once './includes/bootstrap.inc';
require_once './includes/file.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
_executeFile($uri /* e.g.: 'public://OTHER-OpenSourceSystem_1600x1200.jpg' */, $uid);



First function gets two variables as arguments and loads user object
and creates file object from URI, and sets file object properties to
user file field and saves it;
Second piece of code bootstraps system and just calls that function.. You can set your validation rules here