Currently, I'm facing an issue while uploading a file.

I'm fetching the file tid with hook_entity_presave:

$file_tid = $entity->get('field_photos_photos')

if(!empty($file_tid)) {

  $uploaded_file_uri= \Drupal::entityTypeManager()


However, I cannot get the file tid.

  • 2
    There are easier ways, e.g. $uploaded_file_uri = $entity->field_photos_photos->entity->getFileUri(); – Clive May 30 '19 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.