Enable users to download files

I would love to see something like Media view in CakePHP. Basically, I want the user to download files without actually knowing where the files are stored.

Does a feature like this already exist? If yes, please enlighten me about it because it does not seem to be documented.

Yii::app()->request->sendFile($fileName, $content, [$mimeType=NULL, [$terminate=true]]);

That was a heads up. Thanks.

Although, is there any way to override functions in Yii::app()->request? I would like to override this function since it’s memory intensive. If there is, where do I put my code?

Thanks in advance.

Create a class that extends CWebUser and place it under protected/components (or as you wish).

Then configure the request component in your main configuration file and specify ‘class’=>‘application.components.MyNewClass’.


Okay, so I upgraded and the script broke. I cannot seem to understand the change in order of import. How does that matter anyway? Could someone explain me and help me fix my script up? Here is the source of config/main.php file-

return array(


	// autoloading model and component classes







	// application components











It throws an exception and says that WebUserExtension does not have a method named "getPathInfo" whereas the class extends CWebUser.

I think you should set ‘user’ application component instead of ‘request’.

Gah, works now. Thanks again!