使用JSON

时间:2015-12-31 00:57:26

标签: javascript php angularjs json laravel-5

我使用下面的包:

https://github.com/danialfarid/ng-file-upload

我可以触摸我的文件,但我正在运行我的console.log返回一个blob的事实。我怎样才能将其转换为图像?我的console.log如下:

File {$ngfBlobUrl: "blob:http%3A//lt.dev/72bb02fc-94ce-4146-9667-7f35b9c234ed", $ngfWidth: 1200, $ngfHeight: 1600}
  $ngfBlobUrl: "blob:http%3A//lt.dev/72bb02fc-94ce-4146-9667-7f35b9c234ed"
  $ngfHeight: 1600
  $ngfWidth: 1200
  lastModified: 1451421983000
  lastModifiedDate: Tue Dec 29 2015 21:46:23 GMT+0100 (CET)
  name: "20151229124600.jpg"
  size: 414563
  type: "image/jpeg"
  webkitRelativePath: ""
  __proto__: File

目前我只在我的EventController中使用它:

$scope.setFlyer = function ( part )
{
    console.log($scope.flyers.front);
    console.log($scope.flyers.front.$ngfBlobUrl);


    $scope.flyers[part] = {
        blob: $scope.flyers[part].$ngfBlobUrl
    };

};

$scope.updateEvent = function ()
{
    eventFactory.setEvent($scope.event.event, $scope.organisationID, $scope.flyers)
        .then(function ( response )
        {
            if ( response.data.status == 'success' )
            {
                eventFactory.getEvents(1, $scope.organisationID)
                    .then(function ( response )
                    {
                        $scope.events = response.data.events;
                        $scope.event = [];
                        $scope.event.club = [];
                        $scope.event.organisation = [];
                    });
            }
        });
};

我的eventDirective:

setEvent: function ( data, organisationID, flyerSet )
    {
        var json = JSON.stringify({
            json: data,
            organisation_id: organisationID,
            flyers: flyerSet
        });

        return $http.post('/api/v1/event/update', json);
    }

0 个答案:

没有答案