-
-
Save anonymous/ac2ff625a06ad6f3c41ad6f59fdc5f84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div role="form"> | |
<form enctype="multipart/form-data" id="my-form"> | |
<div class="form-group"> | |
<label class="btn btn-primary"> | |
<i class="fa fa-folder-open-o" aria-hidden="true"></i> Seleccionar un archivo | |
<input type="file" accept=".pdf" @change="onFileSelected" name="myfile"> | |
</label> | |
</div> | |
</form> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: "my-component", | |
methods: { | |
onFileSelected (event) { | |
const file = event.target.files[0]; | |
const formData = new FormData($("#my-form")[0]); | |
//const formData = new FormData(); | |
//formData.append("my-file", file); | |
Vue.http.post(`url-to-serve`, formData) | |
.then(res => { | |
//todo ok | |
}, | |
error => { | |
//todo mal :P | |
}) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment