Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从angularjs将文件发送到我的asp.net webapi控制器_Angularjs_File Upload - Fatal编程技术网

从angularjs将文件发送到我的asp.net webapi控制器

从angularjs将文件发送到我的asp.net webapi控制器,angularjs,file-upload,Angularjs,File Upload,我正在尝试上载图像文件。现在,我需要将文件从angularjs发送到我的asp.net web api控制器。我试过几个这样的问题。(我不知道哪里出了问题)这对我没有帮助。有人能帮我解决吗 HTML 在我看来,最好对此使用指令。例如:。您将通过它获得进度报告等,并解决跨浏览器兼容性问题。这里不需要再发明轮子了 <input type="file" file="file" fil onchange="angular.element(this).scope().photoChanged(thi

我正在尝试上载图像文件。现在,我需要将文件从angularjs发送到我的asp.net web api控制器。我试过几个这样的问题。(我不知道哪里出了问题)这对我没有帮助。有人能帮我解决吗

HTML


在我看来,最好对此使用指令。例如:。您将通过它获得进度报告等,并解决跨浏览器兼容性问题。这里不需要再发明轮子了

<input type="file" file="file" fil onchange="angular.element(this).scope().photoChanged(this.files)" />
                <img ng-src="{{ thumbnail.dataUrl }}"width="150" height="150" />
//this is to preview the uplaode image      
$scope.thumbnail = {
            dataUrl: 'adsfas'
        };
        $scope.fileReaderSupported = window.FileReader != null;
        $scope.photoChanged = function (files) {
            if (files != null) {
                var file = files[0];
                if ($scope.fileReaderSupported && file.type.indexOf('image') > -1) {
                    $timeout(function () {
                        var fileReader = new FileReader();
                        fileReader.readAsDataURL(file);
                        fileReader.onload = function (e) {
                            $timeout(function () {
                                $scope.thumbnail.dataUrl = e.target.result;
                            });
                        }
                    });
                }
            }
        };
//after the button pressed
        $scope.AddBanner = function () {


 var request = $http({
                method: 'POST',
                url: urls.api + 'Banner/PostBanner',
                data: data,
                ContentType: multipart/form-data;
                processData: false,
                //data: JSON.stringify(dataObj)



            }).success(function (data, status) {
                alert('saved succesfully');
            })
        .error(function (error) {
            $scope.status = 'Unable to upload Banner Details : ' + error.message;
            console.log($scope.status);
        });

        };