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);