Improve photo upload by preventing empty uploads

Add a check to prevent an upload if no files are selected, displaying an error message.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: f44f1d1b-1dd8-407b-8603-db12902e1a15
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
pac7
2025-10-04 14:23:39 +00:00
parent 51c02388f1
commit 65546141bb

View File

@@ -165,6 +165,12 @@ export function PhotoUpload({
const filesToUpload = isAvatar ? Array.from(files).slice(0, 1) : Array.from(files).slice(0, actualMaxFiles - totalImages);
if (filesToUpload.length === 0) {
setError('No files to upload');
onError?.('No files to upload');
return;
}
// Validate all files first
for (const file of filesToUpload) {
const validationError = validateFile(file);