2017-10-10 2 views
0

내가 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> 

가 지금은 PHP의 값을 mobtain 시도를하지만 난 잘 모릅니다. 나는 이것을 시도했다 :

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

그러나 그것은 작동하지 않았다. 이 작업을 수행하는 좋은 방법이 있습니까?

대단히 감사합니다.

+0

PHP가 사용하는'->'의 객체 연산자에 대한 시도'$ 요청 -> name'과'$ 요청 -> topic' – GentlemanMax

답변

0

내용을 덤프하여 변수가 올바르게 전달되었는지 확인하십시오. 이처럼 :

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

이 모두 덤프한다 : $_POST['topic']$_POST['name']