I have a method for Vuejs component:
async submit () {
if (this.$refs.form.validate()) {
let formData = new FormData()
formData.a
PHP ( process.php )
$_POST,
"files" => $_FILES
);
echo json_encode($data);
?>
Vue and form HTML
let vm = new Vue({
el: "#myApp",
data: {
form: {}
},
methods: {
submit: async function (e) {
e.preventDefault();
/* formData */
var formData = new FormData( this.$refs.formHTML );
/* AJAX request */
await axios({
method: "post",
url: "process.php",
data: formData,
config: { headers: { "Content-Type": "multipart/form-data" } }
})
/* handle success */
.then( response => { console.log(response.data); } )
/* handle error */
.catch( response => { console.log(response) } );
}
}
});