Upload with PHP backend: $_FILE is not set #988
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
change name $_POST to anything, and try vardump. look at developer option