Notice: Undefined index: #value in element_validate_integer_positive() I'm getting the error Notice: Undefined index: #value in element_validate_integer_positive() (line 4190 of includes\form.inc) after clicking the Upload or Remove of a managed_file even though the file is actually being stored in the correct directory.

Here's the relevant snippet:

$form['some_image'] = array(
    '#title' =&gt; t('Image'),
    '#type' =&gt; 'managed_file',
    '#description' =&gt; t('The uploaded image will be displayed on this page using the image style choosen below.'),
    '#default_value' =&gt; variable_get('some_image', ''),
    '#upload_location' =&gt; 'public://some_images/',
  );


I'm running the instance on XAMPP with PHP 5.3.6. Downgrading to PHP 5.2.9 didn't fix the problem as indicated in the other forums.

When I use Chrome to checkout the ajax request URL, I see the message that is also seen from looking at file/ajax/image/file/form-wRaEJ-JRPqC7q6BSbp6Ccxi_9X1cpiaBzhwlIs9NFd0 that I found from /admin/reports/dblog


  Error message An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (512 MB) that this server supports.


Note that I'm only uploading a 100kb file.

Line 4190 of includes/form.inc is as follows:

function element_validate_integer_positive($element, &amp;$form_state) {
  $value = $element['#value'];
  if ($value !== '' &amp;&amp; (!is_numeric($value) || intval($value) != $value || $value &lt;= 0)) {
    form_error($element, t('%name must be a positive integer.', array('%name' =&gt; $element['#title'])));
  }
}


Update: It turns out the problem is not just for the managed_file, but also for the form itself. Clicking the submit button shows the very same error.

Currently, my hook_form_validate is as follows:

function mymodule_form_validate($form, &amp;$form_state) {    
}


Removing it gives me a Drupal error that says it should be there. I think I'm missing an implementation some other hook, but I have no idea which.

What am I missing here?
It sounds that apache user doesn't have the permissions to write in the temp directory which is set in the Drupal's file system settings. 

I'd suggest you to check first the status reports on admin/reports/status. If you have any problems with your installation, it would be listed there.