php - Yii2: Where to store uploaded files? -


story:
user should upload private files server. , should have access files, read(like viewing images or pdf files). placed them not in web root, there no direct link them. after first request, when server publish them authenticated user, becomes available others web/assets/* links.

question:
is there way clear assets every request? or there better way publish private files owners?

you can request file php script (sorry, know yii1 syntax):

?r=resources/get&filename=filename.png  public function actionget() {     $filename = yii::app()->request->getparam('filename');     $filepath = __dir__.'/../../../files/'.$filename;     $finfo = finfo_open(fileinfo_mime_type);     $mime = finfo_file($finfo, $filename);      if (file_exists($filepath) && yii::app()->user->canaccess($filename)) {         header('content-type: '.$mime);         header('content-disposition: inline; filename="'.$filename.'";');         readfile($file);     } else {         $this->redirect('site/index');     } } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -