| import { Effect } from '@alpinejs/effect'; | |
| let init = false; | |
| let posts = []; | |
| function uploadPost() { | |
| const input = document.getElementById('post-input'); | |
| const fileInput = document.getElementById('file-input'); | |
| const file = fileInput.files[0]; | |
| const reader = new FileReader(); | |
| reader.onload = function () { | |
| const data = reader.result; | |
| const blob = new Blob([data], { type: file.type }); | |
| const formData = new FormData(); | |
| formData.append('file', blob); | |
| fetch('/upload-url', { | |
| method: "POST", | |
| body: formData, | |
| headers: { | |
| 'Content-Type': 'application/x-www-form-urlencoded' | |
| } | |
| }) |