Update image in image widget (automatically upload?) on another ajax reference field's autocompleteclose event So I have a few fields that are automagically populated when an entity reference field is 'autocompleted'. Text and Image data (path, etc)

...field_widget_form_alter(&amp;$element, FormStateInterface $form_state, $context) {
    $element['target_id']['#ajax'] = [
      'event' =&gt; 'autocompleteclose',
      'callback' =&gt; 'ajax_callback',
    ];


This is not an issue with text, but how do I update my image-widget (upload field) with a new image path and automagically upload?

...function ajax_callback(array &amp;$form, FormStateInterface $form_state) {

// For text field this is pretty straightforward.
$response-&gt;addCommand(new InvokeCommand('input[name="field_....[' . $delta . '][subform][field_..._name][0][value]"', 'val', [$text]));


Is it possible to pass a path and filename to an image upload input(image-widget) and maybe mock .click() (or something) to trigger an automatic upload when selecting said field reference autocomplete?

Use case (total of 3 fields):
User completes autocomplete field and two additional fields, say description and image (upload input) are automatically populated/image uploaded. (But I can go back if the user wants and update the image (separately) using normal options on the image upload input, if needed.)
No that isn't possible. You can't automate completion of a file input field, it would be a massive security hole (I think browser plugins for chrome/Firefox can do it, but they run in a different security context to website scripts anyway)

If it were possible, anyone with a website could steal any file from any visitor's computer they fancied.