Skip to content

Instantly share code, notes, and snippets.

@remoharsono
Created July 27, 2019 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remoharsono/c2982a974f423b7e70c5c7068a8a41ad to your computer and use it in GitHub Desktop.
Save remoharsono/c2982a974f423b7e70c5c7068a8a41ad to your computer and use it in GitHub Desktop.
<!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