i’m trying to upload my server a file on the device. android upload is good. but ios has trouble.
The response is 200 in the log, and the server does not log the request.
On Android, the request is normal and the upload related log is normal on the server side, but it does not work well on iOS.
This is my code
private instRprtFile(): void {
this.prmt.fileWrteTc = 'C';
let loading = this.loadingCtrl.create({ content: 'Please wait...' });
loading.present();
this.http.post({ url: 'CB102.slctNextFileSno.do', data: this.prmt, isLoading: false }).then((data1: any) => {
this.prmt.fileSno = data1.fileSno;
let isStop = false;
for (let i=0,n=this.items.length; i<n; i++) {
console.log(this.items[i]);
console.log(this.prmt);
let options: FileUploadOptions = {
chunkedMode: false,
fileKey: 'files',
fileName: this.items[i].title,
headers: { 'X-Requested-With': 'XMLHttpRequest' },
params: this.prmt
}
this.fileTransfer.upload(encodeURI(this.items[i].uri), encodeURI('http://localhost:8080/CB102.instRprtFile.do'), options).then((data) => {
if(i == n-1) {
loading.dismiss();
this.sendReport();
}
}).catch((error) => {
console.log(error);
loading.dismiss();
isStop = true;
this.dltnRprt();
this.openErrorMessage(error);
});
this.prmt.fileSno = this.prmt.fileSno + 1;
if(isStop) break;
}
});
}
In the app, CB102.instRptFile.do is called to upload, but the server does not actually response it, so no log is output.
On Android, the log for the CB102.instRptFile.do call comes up normally on the server
config.xml
<plugin name="cordova-plugin-file-opener2" spec="^2.0.19" />
<plugin name="cordova-plugin-filepath" spec="^1.1.0" />
<plugin name="cordova-plugin-filechooser" spec="^1.0.1" />
<plugin name="cordova-plugin-file" spec="^5.0.0" />
<plugin name="cordova-plugin-file-transfer" spec="^1.7.0" />
<engine name="ios" spec="4.5.4" />
<engine name="android" spec="6.3.0" />
ionic info
please help me…
I translated a Google translator about the immature English language.
thank you