Get file from Lightning input type file

With the Spring 17 release one of the new change on the markup is the introduction of the type file to the lightning:input, however I can’t seem to get the file back, only a fakepath with the name of the file.

I’ve tried

<lightning:input aura:id="fileSelector" type="File" label="Upload file"/>

component.find('fileSelector').get('v.files'));

Is there a way to get the file without using a standard input ?

Answer

lightning:input is still beta, and has quite a few problems. It doesn’t even currently have a documented files attribute at the moment. As far as I’m aware, you still need to use a native input element of type “file”.

Attribution
Source : Link , Question Author : Nordine Hammache , Answer Author : sfdcfox

Leave a Comment