Form Post and File Uplaod with AngularJS

I was developing a module using PHP and AngularJS and had to post a form with few fields and a file upload. I did not get any post which to describe the process of adding fileds and logo with AngularJS. I found many blogs for single and multiple file upload methods but not with fields. Here are the steps to develop the form with file upload in AngularJS. In the below example, I am adding an organization with name, address and organization logo.

Step 1.

Add a form Submit controller as “my_controller.js”

I am assuming you have included angular.js and ngfileupload.js with required files.
In the above controller, first we have to add dependency on ngFileUpload Module. Set the mode to add or update and update_id will be false in case of adding new organization.

Submit add organization checks if logo is selected, upload it then call add_organization function else call add_organization without file upload.

Add a HTML file as “my_form.html”

Leave a Reply

Your email address will not be published. Required fields are marked *