1

working on image uploads with Ionic.

When testing my api post with postman it works great, but couldnt get it working with my app.

Trying to debug, I added this to my form:

<input type="hidden" ng-model="projectData.imageBase64" value="testvalue">

And then in my controller:

$scope.projectData = {};
$scope.storeProject = function(projectData) {

    $http.post('http://api.com/api/v1/projects', {
        title: projectData.title,
        image: projectData.imageBase64,
        user_id: $rootScope.currentUser.id
    }).success(function(response) {
        console.log(response);
    }).error(function(response){
        console.log(response);
    });

};

The response from my API (Laravel) is just returning back all the request data asj JSON.

What this returns is no value or record of the image value being passed through.

If I instead change the hidden field to a text field and manually type something then post the form, it is returned back as having input in the request.

Where am I going wrong?

Note: In the form is:

<form ng-submit="storeProject(projectData)">
        <div class="list">
            <label class="item item-input item-stacked-label">
                <span class="input-label">Name</span>
                <input type="text" placeholder="Enter a project name" ng-model="projectData.title">
            </label>

            <input type="hidden" ng-model="projectData.imageBase64" value="ddd">

            <label class="item">
                <button class="button button-block button-positive" type="submit">Create Project</button>
            </label>
        </div>
    </form>

And the title gets passed through fine.

Lovelock
  • 7,689
  • 19
  • 86
  • 186

0 Answers0