I'm building an Android app using Cordova.
I have a form with <input type="file" />
in it.
I would like to send an avatar image via PUT
API method:
$.ajax({
type: 'PUT',
url: my_fancy_api_url,
data:
{avatar: url_to_avatar}
}).done(function(resp){
...
If I send it via web api form everything works fine, but when I'm trying to send it via Cordova app it doesn't change/gets an error that avatar is not a file etc.
My question is: how to get local file url from file input? If I try file_input.value
I get C:/fakepath...
, but if I try file_input.files[0]
or file_input.files[0].name
it doesn't work either - how to get this dynamic path properly? What's the correct way of doing it?
All tutorials about cordova's file / filetransfer plugin has already known path to file, but I don't know how to get it properly.