Get the content of the file by using angular-file-upload

Issue

I create an input for file upload by angular-file-upload

<input type="file" nv-file-select="" uploader="uploader" multiple />

I upload a sample json file –

{
    name: "Alice"
}

and I want to see its content on the onAfterAddingFile event –

onAfterAddingFile function(item) {: Fires after adding a single file to the queue.

uploader.onAfterAddingFile = function (fileItem) {
    console.info('onAfterAddingFile', fileItem.formData); // fileItem.formData is []
}

but the fileItem.formData just contain – []

Here is a jsfiddle

How could I get the content of the uploaded file ?

Solution

onAfterAddingFile – fires after adding file into upload queue. The file itself isn’t uploaded yet, so you can’t reach any content, just meta information. Moreover, as far as I understand, formData {Array}: Data to be sent along with this file means that this is complementary data to send, not file data.

Answered By – Georgy

Answer Checked By – Katrina (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.