Created
July 27, 2019 15:24
-
-
Save remoharsono/c2982a974f423b7e70c5c7068a8a41ad 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
<!DOCTYPE html> | |
<html> | |
<head><title>.</title> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<input type="file" name="filename" id="fileName"> | |
<input type="button" value="Upload" onclick="btnUpload_click()"> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
<script> | |
url = 'http://localhost/api/v1/meeting'; | |
function btnUpload_click() | |
{ | |
var meetingId = 23; | |
var description = 'Blablabla this is description part'; | |
var myFormData = new FormData(); | |
myFormData.set('meeting_id', meetingId); | |
myFormData.set('description', description); | |
var imageFile = document.querySelector('input[name="filename"]'); | |
myFormData.append('filename', imageFile.files[0]); | |
axios({ | |
method: 'post', | |
url: url, | |
data: myFormData, | |
config: { headers: {'Content-Type': 'multipart/form-data' }} | |
}).then(function (response) { | |
console.log('Succeed...'); | |
// console.log(response); | |
}).catch(function (response) { | |
console.log('Error occurred...'); | |
// console.log(response); | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment