The problem could be that the media library folder has the wrong access permissions or wrong ownership, so that wordpress/the webserver is not allowed to write any files into your media folder when you upload images through wordpress.
Your your media library folder is wp-content/uploads.
It depends on your webhoster’s setup how you need to set permissions here.
Try to assign permissions 777 and see if this fixes it. Unfortunately, some hosts are configured so that WordPress uploads work only with these highly insecure permissions. Check with your hoster what permissions are best. (usually you should at most assign folders 755 permissions).
In rare instances, you might also have to switch your folder ownership to the apache user (rather than the ftp user who created the folder).
Read here how to assign permissions:
https://codex.www.ads-software.com/Changing_File_Permissions
Or use a plugin to check your file permissions:
https://www.ads-software.com/plugins/wp-file-permission-check/