uploading file using primeVue

UI Components for Vue
Post Reply
CyberARAB
Posts: 2
Joined: 11 Feb 2021, 17:52

11 Feb 2021, 17:56

Hello, im trying to use FileUpload component to upload a file and store it in a file

Code: Select all

  <FileUpload mode="basic" name="demo[]" @change="loadTextFromFile"/>
  
  
  
  methods: {
  
  async parse(file) {
    const reader = new FileReader();
    reader.readAsText(file);
    const result = await new Promise((resolve, reject) => {
        reader.onload = e => {
        this.$emit("load", e.target.result);
        this.text = e.target.result;
        resolve(reader.result)
        }
    })
  return result
},
   async loadTextFromFile(ev) {
    console.log(ev)
    const file = ev.target.files[0];
    
    const a =  await this.parse(file);
    //const resident = d.residents;
   
    this.$emit("onresident",a)
}


but this is not working with fileUpload however it is working if i use a simple input

CyberARAB
Posts: 2
Joined: 11 Feb 2021, 17:52

12 Feb 2021, 12:10

i also tried to work with the example provided in the PrimeVue website https://www.primefaces.org/primevue/sho ... fileupload
and the playground provided in the sandbox https://codesandbox.io/s/e92yc?file=/sr ... e:965-1094

but nothing works :(

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: avenmore and 2 guests