Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file type validation for image uploads #49

Merged
merged 4 commits into from
Feb 3, 2025
Merged

Conversation

01bps
Copy link
Contributor

@01bps 01bps commented Jan 30, 2025

What:

Implemented client and server-side validation to restrict image upload types to specific formats (.jpg, .jpeg, .png, .gif, .webp, .heif and .pdf).

Why:

  • Prevent users from uploading unsupported file formats
  • Improve user experience by providing immediate feedback
  • Reduce server load by filtering invalid files before upload

How:

  1. Added client-side validation:

    • File type restrictions in file picker dialog
    • JavaScript validation to disable upload button for invalid files
    • Immediate user feedback for invalid selections
  2. Added server-side validation:

    • Implemented ALLOWED_EXTENSIONS check
    • Added allowed_file() helper function
    • Modified upload_image route to validate files
  3. User Interface Updates:

    • Added error message display for invalid files
    • Disabled upload button when invalid file is selected
    • Added accept attribute to file input for better UX

Testing:

  • Verified validation works for all supported file types
  • Confirmed error messages display correctly
  • Validated both client and server-side checks working

Screenshot:

Attachment01

Checklist:

01bps added 2 commits January 31, 2025 17:40
Signed-off-by: Bagwan <[email protected]>
Signed-off-by: Bagwan <[email protected]>
@01bps
Copy link
Contributor Author

01bps commented Feb 3, 2025

Hi @mdxabu ,
I’ve pushed the latest updates and resolved all the conflicts. Please let me know if there’s anything else required.

Thanks!

@mdxabu
Copy link
Collaborator

mdxabu commented Feb 3, 2025

@01bps, Did you pull the recent commit that I merged this morning?

@01bps
Copy link
Contributor Author

01bps commented Feb 3, 2025

@01bps, Did you pull the recent commit that I merged this morning?

The commits merged today were in the main branch. This PR is directed to the dev branch and is up to date with it. Would you like me to update the branch from dev to main and make the necessary updates?

@mdxabu mdxabu merged commit ef67b60 into KathiraveluLab:dev Feb 3, 2025
@01bps
Copy link
Contributor Author

01bps commented Feb 14, 2025

@mdxabu Should we merge this into the main branch as well (As discussed in #30 )? This will help ensure file validation for the drag-and-drop feature.

@01bps
Copy link
Contributor Author

01bps commented Feb 15, 2025

@mdxabu Should we merge this into the main branch as well (As discussed in #30 )? This will help ensure file validation for the drag-and-drop feature.

@mdxabu ,
or I should direct the drag and drop feature to the dev branch only?

@mdxabu
Copy link
Collaborator

mdxabu commented Feb 15, 2025

@mdxabu Should we merge this into the main branch as well (As discussed in #30 )? This will help ensure file validation for the drag-and-drop feature.

@mdxabu , or I should direct the drag and drop feature to the dev branch only?

It will be good for main branch too.

@01bps
Copy link
Contributor Author

01bps commented Feb 15, 2025

@mdxabu Should we merge this into the main branch as well (As discussed in #30 )? This will help ensure file validation for the drag-and-drop feature.

@mdxabu , or I should direct the drag and drop feature to the dev branch only?

It will be good for main branch too.

Alright, I'll create a PR for the main branch as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants