get path of an uploaded file This is my form to upload a photo

 $form['Background_image'] = array(
 '#type' =&gt; 'managed_file',
 '#title' =&gt; t('Choose a background image'),
 '#description' =&gt; t('Click "Browse..." to select an image to upload.'),
 '#required' =&gt; TRUE,
 '#upload_validators' =&gt; array('file_validate_extensions' =&gt; array('jpeg jpg png gif')),
'#upload_location' =&gt; 'public://backgroundimage/',
 '#default_value' =&gt; $this-&gt;options['Background_image'],

);


I tried this function that get the current uploaded image and return its path, but still not working: what is missing:

function image_path()
  {
   $f = file_load($this-&gt;options['Background_image']);
  //this too is not working: 
  //$f = file_load($form_state['values']['Background_image']);
   $url_image = file_create_url($f-&gt;uri);
   print_r($url_image);
   return ($url_image);
  }
In your submit handler of your form, you should be able to retrieve the fid of the uploaded file / image. By using this fid, you can load the file and work with that object.



function YOUR_MODULE_FORM_NAME_submit($form, &amp;$form_state)
{
    $fid = $form_state['values']['Background_image'];

    if ($fid !== 0) {
        // Retrieve image URL
        $image_url = YOUR_MODULE_get_file_url(file_load($fid));
    }
}

function YOUR_MODULE_get_file_url($file)
{
    if (!$file) {
        // File not found
        return false;
    }

    // Return URL from a give file URI
    return file_create_url($file-&gt;uri);
}