I want upload an image file to my PHP webservice.
I made a few requestIDs for my webservice but i dont know how to send the correct requestID to my PHP service.
Image upload is requestID 7. How can I add the requestID or what do I need to change to make it work?
Android code
public void triggerImageUpload() {
makeHTTPCall();
}
// Make HTTP call to upload Image to webservice.
public void makeHTTPCall() {
prgDialog.setMessage("uploading....");
AsyncHttpClient client = new AsyncHttpClient();
//Change link here. client
client.post("#URL",
params, new AsyncHttpResponseHandler() {
// When the response returned by REST has Http
// response code '200'
@Override
public void onSuccess(String response) {
// Hide Progress Dialog
prgDialog.hide();
Toast.makeText(getApplicationContext(), "Done.",
Toast.LENGTH_LONG).show();
Intent myIntent = new Intent(Foto1.this, Foto2.class);
Foto1.this.startActivity(myIntent);
}
PHP Code
if (isset($_POST['requestID'])) {
$requestID = $_REQUEST['requestID'];
if ($requestID = 1) {
//empty
}
if ($requestID = 7) {
// Get image string posted from Android App
$requestID = $_REQUEST['requestID'];
$base = $_REQUEST['image'];
// Get file name posted from Android App
$filename = $_REQUEST['filename'];
// Decode Image
$binary = base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
// Images will be saved under 'uploads' folder
$file = fopen('uploads/'.$filename, 'wb');
// Create File
fwrite($file, $binary);
fclose($file);
echo 'Image upload complete, Please check your php file directory';
}
s working without requestIDs but i want to use it with requestID`s