André Luiz André Luiz - 1 month ago 16x
AngularJS Question

Phalcon + AngularJS upload

I'm working in a form with AngularJS for the front-end and Phalcon PhP for the backend and I'm implementing a upload. I'm using this directive to do so. My problem is that I don't know how handle this upload on a phalcon php action.

Would you have a piece of example code so I could use to start?

Thanks for any help


Something along those lines:

class PostsController extends Controller

   public function uploadAction()
      // Check if the user has uploaded files
      if ($this->request->hasFiles() == true) {

        foreach ($this->request->getUploadedFiles() as $file) {
            $path = 'path/to/file' . $file->getName();
            $isUploaded = $file->moveTo($path);
            echo $isUploaded;

Of course you have to set routing to point to this controller and function.