Android : Reading parameters in file upload in cordova android using php

on Thursday, January 29, 2015


I am trying to implement file upload/download using this plugin(https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md).But i am failed to read the parameters(ie filename,mimetype) from the url.Here is the javascript code



//paramters for upload file
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = uri.substr(uri.lastIndexOf('/') + 1);
options.mimeType = "text/plain";


upload url



var ft = new FileTransfer();
ft.upload(uri, encodeURI('http://192.168.43.211/insiderapp/insiderapp_backend.php?action=uploadfile'), win, fail, options);


win and fail are success and error callback functions actual problem is i can't get options in php file. here is my php



function uploadFile(){
//get the parameters
$options=json_decode(file_get_contents('php://input'));
echo $options->fileKey;
}


It will returns Trying to get property of non-object error.


0 comments:

Post a Comment