[Solved] How to upload image using angularjs php mysql


Yes, You can upload any image or file using AngularJs follow the below steps.
Note here I am uploading the file to store in a folder and not to the database because it’s a bad idea to upload the file into the database instead of that store the file into folder and name of the file in the database.

Step 1: Create the simple view in HTML as below:

<form name="upload_file" id="upload_file" ng-submit="functionName();">    
    <input type="file" name="inputfieldname">
    <button type="submit">Upload</button>
</form>

Now in angular controller write the function as below:

$scope.functionName = function() {
 var formdata = new FormData();
 var filename = document.getElementById('upload_file').files[0];

 formdata.append('filename', filename);

    $http({
        method: 'post',
        url: 'action.php',//Put your php file url
        data: formdata,
        headers: {'Content-Type': undefined},
    }).then(function successCallback(result) {

        $scope.message = result.data;
        alert($scope.message);

    });
}

1

solved How to upload image using angularjs php mysql