mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 05:11:14 -05:00
Fix: Resolve image upload and form integration issues
This commit is contained in:
@@ -202,7 +202,7 @@ export function EntityMultiImageUploader({
|
||||
onUploadComplete={handleUploadComplete}
|
||||
maxFiles={maxImages - value.uploaded.length}
|
||||
variant="compact"
|
||||
allowedFileTypes={['image/jpeg', 'image/jpg', 'image/png', 'image/webp']}
|
||||
allowedFileTypes={['image/*']}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -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