Add image file programmatically in drupal 6 i want to upload an image on my site. I have a custom form in a module with

  $form['picture'] = array(
  '#type'   =&gt; 'file',
  '#title'  =&gt; t('Avatar'),
  '#prefix' =&gt; '&lt;img src="' . $user-&gt;picture . '"&gt;'
  );

  $form['#validate'][] = 'product_validate_picture';


and in my validate fucntion :

$validators = array('file_validate_extensions' =&gt; array('jpg png'),
                    'file_validate_image_resolution' =&gt; array('500x500'));

$file = file_save_upload('picture', $validators);
dsm($file);


The problem is that i do not get the picture returned by the form, i only get "0" which is an error. So, did i do something wrong, or another method is better to get and save a picture returned by a custom form?

Thanks.
This is not good job save file in validation phase and really  where you get file from posted data ? 
file exist in $form_state['value']['picture]

mybe below code help you

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

    $file = $form_state['values']['picture'];

    $validators = array();
    $file = file_save_upload('file', $validators, 'public://');
....