mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: inputs limit to their respective file formats
This commit is contained in:
parent
19cc3ea0d7
commit
b678ac86e8
9 changed files with 55 additions and 6 deletions
20
apps/web/lib/constants.ts
Normal file
20
apps/web/lib/constants.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
export const ACCEPTED_FILE_FORMATS = {
|
||||
video: 'video/*',
|
||||
mp4: 'video/mp4',
|
||||
webm: 'video/webm',
|
||||
image: 'image/*',
|
||||
jpg: 'image/jpeg',
|
||||
png: 'image/png',
|
||||
webp: 'image/webp',
|
||||
pdf: 'application/pdf',
|
||||
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
zip: 'application/zip,application/x-zip-compressed'
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Constructs the 'accept' attribute value for an input element
|
||||
*/
|
||||
export function constructAcceptValue(types : (keyof typeof ACCEPTED_FILE_FORMATS)[]): string {
|
||||
return types.map(type => ACCEPTED_FILE_FORMATS[type]).filter(Boolean).join(",")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue