Ionic image upload with PHP server

I have a problem with my ionic app. I want to upload an image to my php server when i click on a button but it seems that i am doing something wrong…


import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import { HttpClient } from ‘@angular/common/http’;
import { FileTransfer, FileUploadOptions, FileTransferObject } from ‘@ionic-native/file-transfer’;
import { File } from ‘@ionic-native/file’;

selector: ‘communication’,
templateUrl: ‘communication.html’

export class CommunicationPage {

constructor(public navCtrl: NavController,
private transfer: FileTransfer,
private file: File) {}

uploadFile() {

const fileTransfer: FileTransferObject = this.transfer.create();

let options: FileUploadOptions = {
fileKey: ‘ionicfile’,
fileName: ‘ionicfile’,
chunkedMode: false,
headers: {}

var targetPath = this.file.dataDirectory + ‘test.png’;

fileTransfer.upload(targetPath, ‘http://someserver’, options)
.then((data) => {
console.log(data+" Uploaded Successfully");
}, (err) => {

I have this error when i click on the upload button :

FileTransferError {code: 1, source:“filesystem:file:///persistent/test.png”, target: “http://someserver”, http_status: null, body: null, …}

I know there is a problem with the url of the “test.png” file because of code 1 error.

Do you have any idea ?