想请教一下大家,关于在angularJs中进行文件上传时,上传路径该如何定义?比如看到网上有个例子如下:.directive.js中.controller('myCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){ $scope.uploadFile = function(){ debugger; var file = $scope.myFile; console.log('file is ' ); console.dir(file); var uploadUrl = "/file"; debugger; fileUpload.uploadFileToUrl(file, uploadUrl); debugger; }; }]);.service.js中.factory('fileUpload', ['$http', function ($http) { var uploadFileToUrl = function(file, uploadUrl){ var fd = new FormData(); fd.append('file', file); debugger; $http.post(uploadUrl, fd, { transformRequest: angular.identity, headers: {'Content-Type': undefined} }) .success(function(){ alert("图片上传成功!"); }) .error(function(){ alert("error,图片上传失败!"); }); }; return { uploadFileToUrl : uploadFileToUrl }; }]);项目首页请求地址是localhost:3000,但是项目的真实port是8080。那保存文件的路径/file是在哪里?
添加回答
举报
0/150
提交
取消