Changed around line 1
+ document.addEventListener('DOMContentLoaded', function() {
+ const uploadInput = document.getElementById('photo-upload');
+ const uploadBtn = document.getElementById('upload-btn');
+ const gallery = document.getElementById('gallery');
+
+ uploadBtn.addEventListener('click', function() {
+ const files = uploadInput.files;
+ if (files.length > 0) {
+ Array.from(files).forEach(file => {
+ if (file.type.startsWith('image/')) {
+ const reader = new FileReader();
+ reader.onload = function(e) {
+ const imgElement = document.createElement('div');
+ imgElement.classList.add('gallery-item');
+ imgElement.innerHTML = `
`;
+ gallery.appendChild(imgElement);
+ };
+ reader.readAsDataURL(file);
+ }
+ });
+ }
+ });
+
+ // Drag and drop functionality
+ document.body.addEventListener('dragover', function(e) {
+ e.preventDefault();
+ document.body.classList.add('dragover');
+ });
+
+ document.body.addEventListener('dragleave', function() {
+ document.body.classList.remove('dragover');
+ });
+
+ document.body.addEventListener('drop', function(e) {
+ e.preventDefault();
+ document.body.classList.remove('dragover');
+ uploadInput.files = e.dataTransfer.files;
+ });
+ });