31 lines
968 B
HTML
31 lines
968 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Image Upload Example</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<h1>Image Upload Example</h1>
|
|
|
|
<form id="imageUploadForm" enctype="multipart/form-data">
|
|
<input type="file" id="imageInput" name="image" accept="image/*">
|
|
<button type="button" onclick="uploadImage()">Upload Image</button>
|
|
</form>
|
|
|
|
<script>
|
|
function uploadImage() {
|
|
const form = document.getElementById('imageUploadForm');
|
|
console.log(form);
|
|
const formData = new FormData(form);
|
|
|
|
axios.post('http://example.com/upload', formData)
|
|
.then(response => {
|
|
console.log('Image uploaded successfully');
|
|
})
|
|
.catch(error => {
|
|
console.error('Error uploading image:', error);
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |