how to upload an image on ACF with update_field on wordpress
I had the same problem, you almost had it right, which helped me as well.
looked at ACF and the update_field
accepts attachment ID as oppose to the the, pid
or url
You can replace the return array:
return array( 'pid' =>$pid, 'url' =>$file['url']);
With the following array:
return array( 'pid' =>$pid, 'url' =>$file['url'], 'file'=>$file, 'attach_id'=>$attach_id);
and then change
update_field('field_512e085a9372a',$att['url'],$watch);
with the following
update_field('field_512e085a9372a',$att['attach_id'],$watch);
Check this plugin:
https://wordpress.org/plugins/acf-frontend-display/
- Create ACF form with frontendUploader field (plugin extention)
- Add your ACF form into post and with post admin panel use checkbox to view on front