亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關于在angularJS中進行文件上傳時路徑問題

關于在angularJS中進行文件上傳時路徑問題

愛上瘋狂 2016-01-28 15:16:52
想請教一下大家,關于在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是在哪里?
查看完整描述

1 回答

?
pardon110

TA貢獻1038條經驗 獲得超227個贊

網站根目錄下的/file

查看完整回答
反對 回復 2016-01-28
  • 愛上瘋狂
    愛上瘋狂
    可是我在網站根目錄下的file文件夾里并沒發現上傳的文件。
  • 1 回答
  • 0 關注
  • 6847 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號