Hi, I'm trying to save an image file but struggling to get to the actual saving. I'm using Javascript to control my drag and drop at the moment so we get a progress bar that shows up but I'm struggling to actually save the file anywhere. Ideally I'd want to save the file to a "/uploads" folder.
My drag and drop script is `const dropzone = document.getElementById('dropzone');
const browseButton = document.getElementById('browse-button');
const fileContainer = document.getElementById('file');
// Handle drag and drop events
dropzone.addEventListener('dragenter', onDragEnter);
dropzone.addEventListener('dragleave', onDragLeave);
dropzone.addEventListener('dragover', onDragOver);
dropzone.addEventListener('drop', onDrop);
Save image file in Umbraco 10
Hi, I'm trying to save an image file but struggling to get to the actual saving. I'm using Javascript to control my drag and drop at the moment so we get a progress bar that shows up but I'm struggling to actually save the file anywhere. Ideally I'd want to save the file to a "/uploads" folder.
My drag and drop script is `const dropzone = document.getElementById('dropzone'); const browseButton = document.getElementById('browse-button'); const fileContainer = document.getElementById('file');
// Handle drag and drop events dropzone.addEventListener('dragenter', onDragEnter); dropzone.addEventListener('dragleave', onDragLeave); dropzone.addEventListener('dragover', onDragOver); dropzone.addEventListener('drop', onDrop);
// Handle browse button events browseButton.addEventListener('change', onFileSelected);
function onDragEnter(e) { e.preventDefault(); dropzone.classList.add('dragging'); }
function onDragLeave(e) { e.preventDefault(); dropzone.classList.remove('dragging'); }
function onDragOver(e) { e.preventDefault(); }
function onDrop(e) { e.preventDefault(); dropzone.classList.remove('dragging'); const file = e.dataTransfer.files[0]; handleFile(file); }
function onFileSelected(e) { const file = e.target.files[0]; handleFile(file); }
function handleFile(file) { if (!file) return;
}
function createFileItem(file) { const fileItem = document.createElement('div'); fileItem.classList.add('file-item');
}
function uploadFile(file, fileItem) { const formData = new FormData(); formData.append('file', file);
}
function updateProgress(fileItem, percentComplete) { const progress = fileItem.querySelector('.progress'); progress.style.width =
${percentComplete}%
; }`is working on a reply...