發表文章

目前顯示的是 7月, 2015的文章

angular ajax file upload

請看程式上面的注解囉。 找資料很困難,查到怎麼做還蠻簡單=_= HTML <input id="file" name="file" type="file"  /> <input type="button" value="上傳2" ng-click="upload()"/> JS(Controller)  //檔案上傳函數 $scope.upload = function () {   //取得所選的上傳檔案 var file = document.getElementById('file').files[0];   //使用formData去包資料 var formData = new FormData();   //input name , 檔案/資料 formData.append("file", file); $http({  method: 'POST',  url: "Pathangul",  headers: {'Content-Type': undefined},  data: formData }).success(function (data) {  console.log(data); }).error(function () {  alert("error"); }); };