I want to embed user photo(avatar) upload form in a node page like this: node--37.tpl.php so a user can change or upload their profile picture by visiting a particular node.
Can't understand what to do, reading some api documentation like function form_load_include with no luck.Also i found an amazing snippet here but how to use it as a form?

$uid = 3;
$account = user_load($uid);

// suppose that a source user picture is located in the 'sites/default/files/upics'     directory.
// get image information
$image_path = 'public://upics/userpic.jpg';
$image_info = image_get_info($image_path);

// create file object
$file = new StdClass();
$file-&gt;uid = $uid;
$file-&gt;uri = $image_path;
$file-&gt;filemime = $image_info['mime_type'];
$file-&gt;status = 0; // Yes! Set status to 0 in order to save temporary file.
$file-&gt;filesize = $image_info['file_size'];

// standard Drupal validators for user pictures
$validators = array(
  'file_validate_is_image' =&gt; array(),
  'file_validate_image_resolution' =&gt; array(variable_get('user_picture_dimensions',     '85x85')),
  'file_validate_size' =&gt; array(variable_get('user_picture_file_size', '30') * 1024),
);

// here all the magic :)  
$errors = file_validate($file, $validators);
if (empty($errors)) {
  file_save($file);
  $edit['picture'] = $file;
  user_save($account, $edit);
}


Please give me some ideas to get started, your help is really appreciated.
Thanks


Question: how to set default value of properties when object is constructing
Answer: &lt;?php

class model
{
    public $fakeUser = 'user';
    public $ENABLED_IF_LOGIN='disabled',
           $DISABLED_IF_LOGIN='',
           $HIDE_IF_LOGIN='',
           $SHOW_IF_LOGIN='hide',
           $SHOW_IF_EMAIL_VERIFIED='',
           $SHOW_IF_MOB_VERIFIED='',
           $SHOW_IF_INFO_VERIFIED='',
           $SHOW_IF_ADDR_VERIFIED='',

           $HIDE_IF_EMAIL_VERIFIED='',
           $HIDE_IF_MOB_VERIFIED='',
           $HIDE_IF_INFO_VERIFIED='',
           $HIDE_IF_ADDR_VERIFIED='';
}


$dirtyModel = new Model();
$dirtyModel-&gt;fakeUser = 'updatedFakeUser';

var_dump($dirtyModel);

// reset properties
$defaultModel  = new Model();
$defaultValues = get_object_vars($defaultModel);

foreach ($defaultValues as $k =&gt; $v) {
    $dirtyModel-&gt;{$k} = $v;
}

// the object after re-initialised
var_dump($dirtyModel);