Attaching file to node field I have a problem. I'm trying to attach file to node field by this code

function calculator_page_form_validate($form, &amp;$form_state) {
$file = file_save_upload('file', array(
    // Validate extensions.
    'file_validate_extensions' =&gt; array(),
    ));
    // If the file passed validation:
    if ($file) 
    {
            // Move the file into the Drupal file system.
            if ($file = file_move($file, 'public://cunning_files', FILE_EXISTS_RENAME)) {
            // Save the file for use in the submit handler.
            $form_state['storage']['file'] = $file;
        }
        else 
        {
            form_set_error('file', t("Failed to write the uploaded file to the site's file folder."));
        }
    }
    else 
    {
        form_set_error('file', t('No file was uploaded.'));
    }
}
function calculator_page_form_submit($form, &amp;$form_state) 
    {
        $file = $form_state['storage']['file'];
        // We are done with the file, remove it from storage.
        unset($form_state['storage']['file']);
        // Make the storage of the file permanent.
        $file-&gt;status = FILE_STATUS_PERMANENT;
        // Save file status.
        file_save($file);
        $file-&gt;display = 1;
        $file-&gt;description = "";
        // Set a response to the user.
        drupal_set_message(t('The form has been submitted and the image has been saved, filename: @filename.', array('@filename' =&gt; $file-&gt;filename)));
        global $user;
        $node = new stdClass();
        $node-&gt;title = $file-&gt;filename;
        $node-&gt;type = "file";
        //node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().
        $node-&gt;language = LANGUAGE_NONE; // Or e.g. 'en' if locale is enabled
        $node-&gt;uid = $user-&gt;uid;
        $node-&gt;status = 1; //(1 or 0): published or not
        $node-&gt;promote = 0; //(1 or 0): promoted to front page
        $node-&gt;comment = 0; // 0 = comments disabled, 1 = read only, 2 = read/write
        // Term reference (taxonomy) field
        //$node-&gt;field_tag[$node-&gt;language][]['tag'] = $form_state['values']['tag'];
        add_terms_for_node($form_state['values']['tag'], &amp;$node);
        $file-&gt;display = 1;
        $file-&gt;description = "";
        $node-&gt;field_file[$node-&gt;language][0] = (array)$file;
        // 'node' is default,
        // Other possible values are "user" and  "taxonomy_term" 
        $node = node_submit($node); // Prepare node for saving
        node_save($node);
        //drupal_set_message( "Node with nid " . $node-&gt;nid . " saved!\n");
    }


What am i doing wrong? Thank you for help and sorry for my poor engrich it isn't my natural language.
I found mistake. I accidently named field_file as field_fiele. Damn it four houers from life. Code works correctly.