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 Answer 1

1

This is the code to get the size:

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.