drupal form api file upload -


i have form file attachment. once load file , submit form, if validation errors occur form loaded again, file had uploaded not rendered , have load again.

i tried using file_save_upload doesnot seem work.

$file_attach_set= file_save_upload('file_attachment1', array());      //$file_attach_setii = $form_state['values']['attc'];     $contextid = 150;      if(empty($file_attach_setii)){     $form['file_attachment' . $i] = array(       '#type' => 'file',       "#title" =>'kik'       '#default_value'=> $file_attach_set->fid,       //'#title_display' => $file_attach_set->uri,       ''     );     } 

the file element doesn't have #default_value property. try using managed_file type has property.

https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7#file

$form['file_attachment' . $i] = array(     '#type' => 'managed_file',     '#title' =>'kik',     '#default_value'=> array(         'fid' => $file_attach_set->fid,     ), ); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -