Upload and Save an Image in the Server Im currently developing a module that must have a capability to browse/select and upload an image to the server.

function myid_user_page_form(){ 

    $form = array();

    $form['id']['myphoto'] = array(
        '#type' =&gt; 'item',    
        '#markup' =&gt; '&lt;div id="div_myphoto"&gt;&lt;img id="img_myphoto" src="image.png"/&gt;'
    );

    $form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; 'Save',
        '#attributes' =&gt; array(
            'id' =&gt; 'myid_save',               
        ),
        '#submit' =&gt; array('formsave_action'), 
    );  
    return $form;
}

function formsave_action($form,&amp;$form_state) {  

}


How will I upload an image(#img_myphoto) to my server?
Try to implement following code 

function myid_user_page_form(){ 
$form = array();
$form['myphoto'] = array(
  '#type' =&gt; 'managed_file',
  '#title' =&gt; 'File Upload',
  '#upload_validators' =&gt; array('file_validate_extensions' =&gt; array('png gif jpg jpeg')),
  '#upload_location' =&gt; 'public://my-folder/'
   );

$form['submit'] = array(
 '#type' =&gt; 'submit',
 '#value' =&gt; 'Save',
 '#attributes' =&gt; array('id' =&gt; 'myid_save'),
 '#submit' =&gt; array('formsave_action'), 
 );  
 return $form;
}





function formsave_action($form,&amp;$form_state) { 
    $file = file_load($form_state['values']['myphoto']);
    $file-&gt;status = FILE_STATUS_PERMANENT;
    file_save($file);
}