Best Way To Access External Class

Hi, Sorry I am new to Yii and many obvious things you do with normal php seems to be quite different in a MVC environment. so sorry if this is a dumb question.

I am trying to make use of an upload class I found, which consists of some client code and a server php file. The client code will need to call the server php, via a ajax call.

The client code I have placed in a view file. e.g. view.php. however I am confused to where to put the server php file. Currently it’s under protected/extension/3rdparty.php, I understand I can’t access anything under protected directly, if that the case, what is the best way to achieve this? (the only way I can think off is to create another action/view, and place the php code under the new view file.

Thanks in advance.

jas

You could create a controller that uses the protected/extension/3dparty.php file. And then you can make Ajax calls from the view.php to this new controller.

You can just place your server.php under webroot, so it can be accessible from the web, and place client script somewhere it can be reached from server.php.

There’s no need to use MVC everywhere.

PS. The MVC alternative:

Create separate controller (for example, AjaxController.php) or use one of existing (for example, SiteController.php).

Create an action (for example, actionUpload). Place the code from server.php into this action.

Create a view upload.php, place a code from view.php to it.

Then you can call this via /ajax/upload.

Thanks Orey, the first option my concern is security, as the server.php handles file upload.

And thanks for the MVC alternative, I am thinking along similar lines, and it’s great to have bit of confirmation!! Thanks & Cheers!!!

Thanks Roman!!