I am creating simple application in angularjs using slim framework. In that, I am creating form for some data like name, categories, currency and Image file etc. In this app, I am having trouble with input type file. I can get all the data of textbox or radio button etc but I can't get data of input type file. Below is the code for that.
index.html :- HTML file
<form method="POST" enctype="multipart/form-data" class="form account-form" name="form" ng-submit="creator(user)" role="form">
<input type="text" name="name" ng-model="user.name" />
<input type="radio" name="category" ng-model="user.category" value="Science" >
<input type="radio" name="category" ng-model="user.category" value="Engineerig" >
<input type="file" ng-model="user.image_file" name="image_file">
</form>
registerController.js :- Controller file
app.controller('CreatorController', function($scope,$rootScope,$location,$http,CreatorService,FlashService) {
$scope.creator = function (user) {
// alert("create");
$scope.dataLoading = true;
CreatorService.creator(user)
.then(function (response) {
if(response.data['message']){
FlashService.Success('Registration successful', true);
$location.path('/crete-page');
} else {
FlashService.Error('Registration failed');
}
});
}
});
registerDB.php :- DB handler PHP file in slim framework dir
<?php
function insertUser($data) {
print_r($data); //Getting All data here from form but not getting File values
}
?>