How can I can make default profile picture when the user have not upload there picture? I want to display default profile picture for them, like png.
I have done some thing similar in php but I don’t know how to change it to nodejs express code.
This is what have done in php:
$target_dir = "uploads/"; $defaultProfilePicture = "static/" . basename("0000.png"); $defaultContentType = "image/png;";
How can I change it to express code? Please help me by saving my days. Thanks
Advertisement
Answer
If your using mongoose in your user model make a field for profile picture and you can set a default value
Example
const schema = new Schema({ name: String, role: { type: String, default: 'guitarist' } });