title: Why isn't my file upload working in Drupal 7?
body: <p>I have a custom module and I want a field to upload a picture. Chrome appears to upload the file, but it's not working and I get the error below. Can someone please point me in the right direction?</p>
  
  <pre><code>function nafa_adoption_form($form_state)
  {
    $form['#attributes'] = array('enctype' =&gt; "multipart/form-data");
  
    ...
  
    $form['picture'] = array(
      '#type' =&gt; 'file',
      '#title' =&gt; t('Picture'),
      '#size' =&gt; 20,
      '#upload_location' =&gt; 'public://uploads'
    );
  
    $form['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Save'),
    );
  
  
  
  
    return $form;
  }
  </code></pre>
  
  <p>Submit function:</p>
  
  <pre><code>function nafa_adoption_form_submit($form, &amp;$form_state) 
  {
  
  
    dvm($form_state['values']); //field 'picture' is blank
  
    $file = file_load($form_state['values']['picture']);
  
    $file-&gt;status = FILE_STATUS_PERMANENT;
  
    file_save($file);
  
    $fileid = file_load($file);
  
    variable_set('adoption_picture', $fileid-&gt;uri);
  
    if ($file)
    {
      drupal_set_message("File uploaded ");
    }
  
    else
    {
      drupal_set_message("File could not be uploaded");
    }
  
    drupal_set_message(t('Your form has been saved.'));
  }
  </code></pre>
  
  <p>I also get the following error:</p>
  
  <pre><code>Notice: Undefined property: stdClass::$uri in file_save() (line 573 of /home/amn7940/nafa.achristiansen.com/includes/file.inc).
  </code></pre>