danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.59k forks source link

Can't send email with file #2036

Open kapeeeek opened 6 years ago

kapeeeek commented 6 years ago

Hi, thanks for this pretty good tool.

I've got a problem with email attachment.

My html:

<input type="file" ng-file-select="onFileSelect($files)"/> <button type="button" class="btn btn-success btn-lg" ng-click="sendEmail()"> <span class="glyphicon glyphicon glyphicon-send"></span> Send </button>

Then in my JS:

$scope.sendEmail= function(){
    var file = $files[0];
    $scope.emailData = new EmailData();
    $scope.emailData.to = "example@gmail.com";
    $scope.emailData.from = "example2@gmail.com";
    $scope.emailData.subject = "Sending issue";
    $scope.emailData.type= "Type";
    $scope.emailData.title = $scope.data.topic;
    $scope.emailData.description= $scope.data.description;
    $scope.emailData.template = "templateErrors";

    Upload.upload({
        url: 'sendemail/attachment',
        data: {$scope.emailData},
        file: file,
        }).success(function(data, status, headers, config) {
            console.log(data);
        });
}

Someone can help me?