yii2
When the actionDownloadFile() function is invoked, it will look for files in the ImportForm\EXAMPLE_DIR directory that have the .filter file extension. If the file path includes the .filter file extension, the path will be returned; otherwise, false will be returned.
public function actionDownloadFile($type)
{
$filePath = FileHelper::findFiles(ImportForm::EXAMPLE_DIR, ['filter' => function($path) use ($type) {
if (strpos($path, $type)) {
return $path;
}
return false;
}]);
return Yii::$app->response->sendFile(...$filePath);
}