After extensive research, I have been exploring how to enable direct browser uploads, particularly in the context of utilizing Stripe with Google App Engine, as discussed on this forum. The Stripe documentation also mentions the possibility of browser uploads here.
Despite my attempts with AJAX, it appears that obtaining the path to a local file is not feasible due to security restrictions. The code snippet below represents the closest progress I have made, but I am struggling to figure out a way to upload an image from the browser without involving the server. The console keeps showing an error message stating "Invalid file: must be uploaded in a multipart/form-data request".
My next step is to experiment with the Jquery Form Plugin, although I am uncertain about the likelihood of success with that approach.
var formData = new FormData($('#theHTMLForm')[0]);
var sendarray={purpose:"identity_document", file:formData};
sendarray=JSON.stringify(sendarray);
$.ajax({
type:'POST',
url: 'https://uploads.stripe.com/v1/files',
data: sendarray,
mimeType: "multipart/form-data",
headers: {
"Authorization": "Bearer STRIPEPUBLISHABLEKEY"
},
contentType: 'application/json',
processData: false,
success:function(data){
alert('success');
console.log(data);
},
error: function(data){
alert('error');
console.log(data);
}
});