File upload with ajax
Maybe this will be helpful (in a custom module): 

function testmodule_forma($form, &amp; $form_state) {
    $form['im-container'] = array(
        '#prefix' =&gt; '&lt;div id="im-area"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;',
    );

    $form['image_file'] = array(
        '#type' =&gt; 'file',
    );

    $form['upload'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; 'upload',
        '#submit' =&gt; array('upload_image'),
        '#ajax' =&gt; array(
            'callback' =&gt; 'upload_image',
            'wrapper' =&gt; 'im-area',
            'method' =&gt; 'replace',
            'effect' =&gt; 'fade',
        ),
    );
    return $form;
}

function upload_image($form, $form_state) {

    $file = file_save_upload('image_file', array('file_validate_extensions' =&gt; array('png gif jpg jpeg')), "public://", FILE_EXISTS_REPLACE);
    if ($file) {
        $file-&gt;status = FILE_STATUS_PERMANENT;
        file_save($file);
        $form['im-container'] = array(
            '#title' =&gt; t('Preview:'),
            '#prefix' =&gt; '&lt;div id="im-area"&gt;',
            '#markup' =&gt; '&lt;img src="sites/default/files/'.$file - &gt; filename.
            '" height="250" width="250" /&gt;',
            '#suffix' =&gt; '&lt;/div&gt;',
        );
    } else {
        drupal_set_message('No file uploaded.');
    }

    return $form['im-container'];
}