flowjs / ng-flow

Flow.js html5 file upload extension on angular.js framework
http://flowjs.github.io/ng-flow/
MIT License
1.38k stars 303 forks source link

Could I post the image as base64 in JSON? #45

Open tombujok opened 10 years ago

tombujok commented 10 years ago

Hi,

Maybe it's a stupid idea buy I am using a groovy server and I wouldn't mind if I could get the image as base64. I don't want to use the upload.php file. Is there a way to bind the base64 string to a ng-model?

Many thanks! Tom

PazkaL commented 10 years ago

Try something like this:

            $scope.$on('flow::fileAdded', function (event, $flow, flowFile) {
                var reader = new FileReader();
                reader.onload = function(event) {
                    $scope.filedata = event.target.result.substr(event.target.result.indexOf('base64')+7);
                    $scope.filename = flowFile.file.name;
                };
                reader.readAsDataURL(flowFile.file);
            });