如何检查文件是否已从HTML前端上载到python后端?

如何检查文件是否已从HTML前端上载到python后端?,python,Python,我在前端有一个HTML和angularJS代码,可以在后端上传一个文件。如何检查文件是否已在python中上载 https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"> 上传我 var myApp=angular.module('myApp',[]); myApp.directive('fileModel',['$parse',function($parse){ 返回{ 限制:“A”, 链接:函数(范

我在前端有一个HTML和angularJS代码,可以在后端上传一个文件。如何检查文件是否已在python中上载

https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">


上传我
var myApp=angular.module('myApp',[]);
myApp.directive('fileModel',['$parse',function($parse){
返回{
限制:“A”,
链接:函数(范围、元素、属性){
var model=$parse(attrs.fileModel);
var modelSetter=model.assign;
元素绑定('change',function()){
作用域$apply(函数(){
modelSetter(作用域,元素[0]。文件[0]);
});
});
}
};
}]);
myApp.service('fileUpload',['$https:',函数($https:){
this.uploadFileToUrl=函数(文件,uploadUrl){
var fd=新FormData();
fd.append('file',file);
$https:.post(上传URL、fd、{
请求:angular.identity,
标题:{'Content-Type':未定义}
})
.success(函数(){
})
.错误(函数(){
});
}
}]);
myApp.controller('myCtrl',['$scope','fileUpload',函数($scope,fileUpload){
$scope.uploadFile=函数(){
var file=$scope.myFile;
log('file is');
console.dir(文件);
var uploadUrl=“/fileUpload”;
uploadFileToUrl(文件,uploadUrl);
};
}]);

请分享您的代码。您的代码已添加。请参见上面:)@TomažBratanič
  <div ng-controller = "myCtrl">
     <input type = "file" file-model = "myFile"/>
     <button ng-click = "uploadFile()">upload me</button>
  </div>

  <script>
     var myApp = angular.module('myApp', []);

     myApp.directive('fileModel', ['$parse', function ($parse) {
        return {
           restrict: 'A',
           link: function(scope, element, attrs) {
              var model = $parse(attrs.fileModel);
              var modelSetter = model.assign;

              element.bind('change', function(){
                 scope.$apply(function(){
                    modelSetter(scope, element[0].files[0]);
                 });
              });
           }
        };
     }]);

     myApp.service('fileUpload', ['$https:', function ($https:) {
        this.uploadFileToUrl = function(file, uploadUrl){
           var fd = new FormData();
           fd.append('file', file);

           $https:.post(uploadUrl, fd, {
              transformRequest: angular.identity,
              headers: {'Content-Type': undefined}
           })

           .success(function(){
           })

           .error(function(){
           });
        }
     }]);

     myApp.controller('myCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){
        $scope.uploadFile = function(){
           var file = $scope.myFile;

           console.log('file is ' );
           console.dir(file);

           var uploadUrl = "/fileUpload";
           fileUpload.uploadFileToUrl(file, uploadUrl);
        };
     }]);

  </script>