How to get files from root folder

How to get files from root folder in yii2 advanced template

I have uploaded files in _protected/frontend/uploads folder.

_protected folder is in root folder.

How can I get these files from public_html?

I think you have two solutions:

  1. Give public permission to _protected/frontend/uploads (discouraged);

  2. Create a Controller action that acts as a proxy between public and private zones;

I was thinking something like solution 2.

I need to show files to members in security area.

What is a good way to show .doc and .pdf files in this situation?

readfile() or file_get_contents()