Fix file upload reset issue - complete solution
✅ File Input Reset Fix: - Completely recreate file input element on reset to clear all state - Remove and recreate DOM elements to eliminate cached event listeners - Add comprehensive logging for debugging file selection issues - Force clear file input value and recreate with fresh event handlers ✅ Event Listener Management: - Clone and replace upload area to remove stale event listeners - Reinitialize all drag & drop and click event handlers - Ensure file input click events work after multiple uploads - Add proper event propagation handling ✅ Upload Area Reinitialization: - Create initializeUploadArea() function for complete reset - Remove existing file input and create brand new element - Reattach all event listeners to fresh DOM elements - Add console logging for debugging upload flow ✅ Robust State Management: - Clear uploadedFile variable on reset - Hide upload controls and results sections - Remove 'Upload Another' buttons properly - Ensure clean state between file uploads This should completely resolve the file upload reset issue where users had to reload the page to upload a second file.
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
<i class="fas fa-cloud-upload-alt upload-icon"></i>
|
||||
<p>Drag and drop an image here or click to select</p>
|
||||
<p class="upload-hint">Supported formats: PNG, JPG, JPEG, GIF, BMP</p>
|
||||
<input type="file" id="fileInput" accept="image/*" style="display: none;">
|
||||
<input type="file" id="fileInput" accept="image/*" style="display: none;" multiple="false">
|
||||
<button class="btn btn-outline" onclick="document.getElementById('fileInput').click()">
|
||||
Select Image
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user