Tag Archives: file

File Upload with Angular 2 and Laravel 5

Ok the latest hurdle was handling File uploads via Angular JS 2, and receiving it on the API end in Laravel 5.

I realised there wasn’t a lot of resources on the internet about this, and earlier reports shown that file uploading was not supported in Angular JS 2. Thankfully, this is now possible and quite easy.

First to set up the file upload on Angular JS 2.

Simply set up a file input component, you can wrap it in a directive, but for simplicity’s purposes, I am simply listening to a generic input here.

In the view,

In the component, we have a fileUpload method which listens on any changes to the input, if so, we upload the file to the API.

And on the receiving controller in Laravel, it’s as simple as: