I have this webform submission hook and i want to add a file to it when its submitted. I know how to alter the webform submission but now i have an issue that i want to load a file but i don’t know the id, only it’s url:
Url: /sites/default/files/assets/filename.pdf
i have tried:
$file_name = Drupal::service('file_system')->basename($filename); //$file_name gives me the correct name $target_file = Drupal::entityTypeManager()->getStorage('file') ->loadByProperties(['filename' => $file_name]); //$target_file is an empty array
How can i get the file id by its url
Any help is welcome 😀