0

Hi I have the filename and fid of the uploaded file in a media entity, how can I programatically get the size and last uploaded date in my module? This is with D8 thanks

1

This is the code to get the size:

 $tid=$fileupload[0]['target_id'];
 $file = File::load($tid);
 $size = $file->getSize();
  • Use like \Drupal\file\Entity\File::load($tid) or add use Drupal\file\Entity\File at top of the file – siddiq Apr 5 '18 at 6:23

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.