Saturday, January 28, 2023
HomeiOS Developmentios - ionic capacitor app Failing to add file utilizing xhr

ios – ionic capacitor app Failing to add file utilizing xhr


i’m making an attempt to add picture captured from digicam utilizing ionic and capacitor and under code i’m utilizing:

var url="https://api.cloudinary.com/v1_1/" + this.cloudName + '/picture/add';
var xhr = new XMLHttpRequest();
var fd = new FormData();
xhr.open('POST', url, true);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Entry-Management-Permit-Origin","*")
xhr.onreadystatechange = (e) => {
this.loading = false;
if (xhr.readyState == 4 && xhr.standing == 200) {
// File uploaded efficiently
var response = JSON.parse(xhr.responseText);
var url = response.secure_url;
// Create a thumbnail of the uploaded picture, with 150px width
var tokens = url.cut up("https://stackoverflow.com/");
tokens.splice(-2, 0, 'w_150,c_scale');
var img = new Picture(); // HTML5 Constructor
img.src = tokens.be a part of("https://stackoverflow.com/");
img.alt = response.public_id;
doc.physique.appendChild(img);
//window.alert(url);
this.imageUrl = url;
this.capturedImage = this.base64Image;
//alert('seize:' + capturedImage);
}else{
console.log("unable to load picture to the cloud" + xhr.readyState + ":" + xhr.standing + ":" + xhr.responseText)
}
};

fd.append('upload_preset', this.unsignedUploadPreset);
fd.append('tags', emailid); // Optionally available - add tag for picture admin in Cloudinary
fd.append('file', this.base64Image);
xhr.ship(fd);

it prints: unable to load picture to the cloud 4:0:



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments