I have a problem uploading files with Ionic and ng2-file-upload. Apparently server is receiving all adaditional POST parameters, but isset($_FILE['myfile']) returns false.
On submit.html there is:
<input type="file" name="myfile" [(ngModel)]="myfile" ng2FileSelect [(uploader)]="uploader" />
Hello,
I have a problem uploading files with Ionic and ng2-file-upload. Apparently server is receiving all adaditional POST parameters, but
isset($_FILE['myfile'])
returns false.On submit.html there is: <input type="file" name="myfile" [(ngModel)]="myfile" ng2FileSelect [(uploader)]="uploader" />
On submit.ts: this.uploader.onBuildItemForm = (fileItem: any, form: any) => { form.append('user' , this.user); form.append('token' , this.token); [...] }; this.uploader.uploadAll(); this.uploader.onSuccessItem = (item: any, response: string, status: number, headers: any): any => { if(response){ console.log("submit response: "+JSON.stringify(response)); } }
And on submit.php: $_POST = json_decode(file_get_contents('php://input'), true);
$user = $_POST['user']; $token = $_POST['token'];
if((isset($_FILES["myfile"]))) { [...]
myfile parameter is empty. Do you know what can be happening? Any help is appreciated.