File Upload With Ng-file-upload Throwing Error
I'm using ng-file-upload for uploading an image file. The code for html for the upload button is
Solution 2:
if you want to go for vanilla js , this piece of code will work for any library or no library and compatible with ng-file-upload -
var xhr = newXMLHttpRequest();
xhr.withCredentials = true;
var formData = newFormData;
formData.append('YOUR_FILE_OBJECT_NAME', file);
xhr.addEventListener("readystatechange", function() {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "YOUR_URL_HERE");
xhr.send(formData);
Copy
Post a Comment for "File Upload With Ng-file-upload Throwing Error"