drupal 8 file upload path on node_presave hook

1.1k Views Asked by At

I need to find the file uploaded path on node_presave hook

   function hooks_example_node_presave(EntityInterface $node) {

var_dump($node->field_image_upload->getValue()); exit;

    }

This is what I tried. Help would be appreciated. Thanks Raj

2

There are 2 best solutions below

0
rajmohan On BEST ANSWER

I found solutions. Following will get the uploaded file url.

$node->field_image_upload->entity->url()
0
Asif On

You need to write this

function hooks_example_node_presave(Drupal\Core\Entity\EntityInterface $entity) {

 $image = $entity->field_seedit_thumbnail_image->getValue();

 $fid = !empty($image[0]['target_id']) ? $image[0]['target_id'] : '';

}