How to Get full File Path of Image and Upload it to server

I am following this link to upload image.
I am able to select and display it.
but i want it full path so that i can copy it to the local place and then upload it to server.

Best Answer


  • Thanks @KellyHuss for your help.
    It is working fine.

  • sivabhavanisivabhavani USMember ✭✭

    For me it is not working ..can you please help out.

    this is my manifest file

  • FahadAliQureshiFahadAliQureshi Member ✭✭

    @sivabhavani said:
    For me it is not working ..can you please help out.

    this is my manifest file

    This is the permission fault. You have to Check and Request Permissions dynamically at runtime. For this, use the James montemagno's permission plugin. link also given below: plugin

  • Franck_SDEAFranck_SDEA Member ✭✭
    edited January 31

    @KellyHuss : Two years later... :D

    I use your Android Implementation for pick a picture. If I pick a picture from the "Recents" category, thats work fine but, if I pick an image from the one of theses category (see screenshot), it crash !

    In Visual Studio the error is:

    Unhandled Exception:

    Java.Lang.IllegalArgumentException: Invalid URI: content://

  • Franck_SDEAFranck_SDEA Member ✭✭

    I have found a solution, I post here for others...

    private string GetPathToImage(Android.Net.Uri uri)
        string doc_id = "";
        using (var c1 = ContentResolver.Query(uri, null, null, null, null))
            string document_id = c1.GetString(0);
            doc_id = document_id.Substring(document_id.LastIndexOf(":") + 1);
        string path = null;
        // The projection contains the columns we want to return in our query.
        string selection = Android.Provider.MediaStore.Images.Media.InterfaceConsts.Id + " =? ";
        using (var cursor = ContentResolver.Query(Android.Provider.MediaStore.Images.Media.ExternalContentUri, null, selection, new string[] { doc_id }, null))
            if (cursor == null) return path;
            var columnIndex = cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
            path = cursor.GetString(columnIndex);
        return path;
Sign In or Register to comment.