1

I am facing a big issue in Vue.js that when i am trying to send the data from Upload.vue to my controller in laravel 5.3 i am getting null values in it

My code is

My .vue file :

this.file = document.getElementById('video').files[0];            
var formData = new FormData();
formData.append('video', this.file);
formData.append('uid', this.uid);
console.log(this.file);
console.log(this.uid);
console.log(formData);
this.$http.post('/upload',formData,..... 

on console i am getting this :

this is when i print my "this.file"

File
lastModified:1475310793454
lastModifiedDate:Sat Oct 01 2016 14:03:13 GMT+0530 (India Standard Time)
name:"HQim.in.mp4"
size:20773807
type:"video/mp4"
webkitRelativePath:""
__proto__:File

when i console my formData i get this

FormData
__proto__:FormData
append:append()
constructor:FormData()
delete:delete()
entries:entries()
forEach:forEach()
get:get()
getAll:getAll()
has:has()
keys:keys()
set:set()
values:values()
Symbol(Symbol.iterator):()
Symbol(Symbol.toStringTag):"FormData"
__proto__:Object

nothing is available even when i appended i searched a lot but none benefitted i am using "vue": "^1.0.26", "vue-resource": "^1.0.2"

Help me guys

3
  • Have a look at developer.mozilla.org/en-US/docs/Web/API/FormData/get Commented Mar 25, 2017 at 12:34
  • that does solves my error sir Commented Mar 25, 2017 at 14:14
  • Actually if i am passing only "uid" without using formdata that is passing but not the "file" so i have to use formdata but it is not working Commented Mar 25, 2017 at 14:15

1 Answer 1

1

use this, may this help you...

npm install axios

or

bower install axios

then

import axios from 'axios'


            var datas = new FormData()

            datas.append('postMessage', this.postMessages)
            datas.append('postPicture', this.postPicture)


axios.post('your_url_here', datas , {headers: {'Content-Type': 'multipart/form-data'}})
                .then((response) => {
                    //if success
                    console.log(response)
                  },
                  (response) => {
                   //if error occures 
                   console.log(response)
                  })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.