I am trying to upload the selected File to a server and i seem to have run into a wall when it comes to starting the upload activity when the "uploadbtn" button is clicked, so the question is which roots should i follow to successfully upload the file selected? any advice is greatly appreciated. I have completed the php and mysql side of this app, below is the majority of my code except the php and mysql code.
public void onClick(View v) {
switch (v.getId()) {
case R.id.filetoupload:
Intent fileintent = new Intent(Intent.ACTION_GET_CONTENT);
fileintent.setType("application/*");
startActivityForResult(fileintent, RESULT_LOAD_FILE);
break;
case R.id.uploadbut:
break;
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case RESULT_LOAD_FILE:
if (requestCode == RESULT_LOAD_FILE && resultCode == RESULT_OK
&& null != data) {
Uri selectedPdf = data.getData();
filetoupload.setVisibility(View.VISIBLE);
if (selectedPdf.getLastPathSegment().endsWith("pdf")) {
System.out.println("Uri of selected pdf---->" + selectedPdf.toString());
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Invalid file type", Toast.LENGTH_SHORT).show();
}
}
}
}