export const Uploads = new FilesCollection({
collectionName: 'uploads',
allowClientCode: false,
storagePath: "/Applications/Ampps/www/elaadmin/public/",
onBeforeUpload(file) {
if (/jpeg|png|jpg/i.test(file.extension)) {
return true;
} else {
return "Invalid file format";
}
}
});
Hello @pdshah3690,
storagePath can be a function and invoked with fileRef upon upload. See mode details in the Constructor docs
Feel free to close it in case if the issue is solved on your end.
@dr-dimitru It worked. Thanks for this solution.
export const Uploads = new FilesCollection({
collectionName: 'uploads',
allowClientCode: false,
storagePath: function(file) {
if(file.meta) {
return "/Applications/Ampps/www/elaadmin/public/uploads/"+file.meta.type+"/";
}
return "/Applications/Ampps/www/elaadmin/public/uploads/";
},
onBeforeUpload(file) {
if (/jpeg|png|jpg/i.test(file.extension)) {
return true;
} else {
return "Invalid file format";
}
}
});
@pdshah3690 I'm glad you solved it so quickly.
Please support this project with: