上传值在VUE PHP和POST

问题描述:

我在VUE以下功能组件:上传值在VUE PHP和POST

<template> 
    <div id="configurations"> 
    <h4>Select your input files!</h4> 
    <form enctype="multipart/form-data" @submit.prevent="submitForm" align="left" id="imageForm"> 
    <input v-model="inputTable.topic" name="topic" debounce="500"> {{inputTable.topic}} <br> 
    <input v-model="inputTable.name" name="name" debounce="500"> {{inputTable.name}} <br> 
    <button type="submit">Save</button> 
    </form> 
    </div> 
</template> 

<script> 
import VueResource from 'vue-resource' 
export default { 
    data() { 
    return{ 
     inputTable: { 
     topic: '', 
     name: '' 
    }}}, 

    methods: { 
    submitForm: function() { 
     var data = this.inputTable 
     this.$http.post('/api/santander/php/updatedata.php', data).then(function(response) { 
      //this.updated = true; 
     }) 
    }}} 
</script> 

现在我尝试mobtain在PHP中的值,但我不知道怎么办。我试过这个:

$request = json_decode(file_get_contents('php://input')) 
$field = $request.name; 
$name = $request.field; 

但是没有奏效。有没有什么好方法可以做到这一点?

非常感谢您提前。

+0

PHP使用' - >'的目的操作,尝试'$请求 - > name'和'$请求 - > topic' – GentlemanMax

尝试转储$_POST内容以查看您的变量是否正确传入。就像这样:

class updatedate { 
    public function index { 
     var_dump($_POST); 
    } 
} 

这应该转储上述两个:$_POST['topic']$_POST['name']