mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 02:51:13 -05:00
Fix: Resolve image upload and form integration issues
This commit is contained in:
@@ -77,15 +77,20 @@ export function UppyPhotoUpload({
|
||||
return `File "${file.name}" exceeds ${maxSizeMB}MB limit`;
|
||||
}
|
||||
|
||||
const allowedTypes = allowedFileTypes.map(type =>
|
||||
type.replace('*', '').replace('/', '')
|
||||
);
|
||||
|
||||
if (!allowedTypes.includes('image') && !allowedFileTypes.includes('image/*')) {
|
||||
const fileType = file.type.split('/')[0];
|
||||
if (!allowedTypes.includes(fileType)) {
|
||||
return `File type "${file.type}" is not allowed`;
|
||||
// Check if file type is allowed
|
||||
// Support both wildcard (image/*) and specific types (image/jpeg, image/png)
|
||||
const isWildcardMatch = allowedFileTypes.some(type => {
|
||||
if (type.includes('*')) {
|
||||
const prefix = type.split('/')[0];
|
||||
return file.type.startsWith(prefix + '/');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
const isExactMatch = allowedFileTypes.includes(file.type);
|
||||
|
||||
if (!isWildcardMatch && !isExactMatch) {
|
||||
return `File type "${file.type}" is not allowed`;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user