私はそれを動作させました、これが私が使用したコードです
uploadFile('test.zip', 'Test', 'multipart/x-zip');
function uploadFile(fileName, dirName, fileMime) {
var win = function(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
alert(r.response);
};
var fail = function(error) {
alert("An error has occurred: Code = " = error.code);
};
var fileURI;
var gotFileSystem = function(fileSystem) {
fileSystem.root.getDirectory(dirName, {
create : false
}, function(dataDir) {
fileURI = dataDir.fullPath;
fileURI = fileURI + '/' + fileName;
alert(fileURI);
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
options.mimeType = fileMime;
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
var ft = new FileTransfer();
ft.upload(fileURI,
// Enter the server url
"http://example.com/upload.php", win,
fail, options);
}, dirFail);
};
// file system fail
var fsFail = function(error) {
alert("failed with error code: " + error.code);
};
// get file system to copy or move image file to
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem,
fsFail);
var dirFail = function(error) {
alert("Directory error code: " + error.code);
};
}