這很簡單。這將只在離子FW
首先你必須安裝文件傳輸插件。如果沒有使用這個命令:
cordova plugin add org.apache.cordova.file-transfer
承擔http://www.samplewebsite.com/upload。是您的服務器超鏈接。
example.controller("ExampleController", function($scope, $cordovaFileTransfer) {
$scope.upload = function() {
var options = {
fileKey: "avatar",
fileName: "filename.mp4",
chunkedMode: false,
mimeType: "video/mp4"
};
$cordovaFileTransfer.upload("http://www.samplewebsite.com/upload", "file:/storage/....mp4", options).then(function(result) {
console.log("SUCCESS: " + JSON.stringify(result.response));
}, function(err) {
console.log("ERROR: " + JSON.stringify(err));
}, function (progress) {
// constant progress updates
});
}
});
畢竟你需要調用這個函數像這樣
<button class="button" ng-click="upload()">video upload</button>
其工作。我做了很多次。
你需要使用文件上傳插件:http://ngcordova.com/docs/plugins/fileTransfer/來上傳它。 –