While uploading an image through WordPress media, if you get an error that the attachment could not be inserted into the database,.
Could not insert attachment into the database.
This is because the file name you are trying to upload doesn’t match the accepted criteria for file name to upload. Most of this error is due to the large text in the file name, so try to reduce the text in file name.
How to fix could not insert attachment into the database error?
There is no hard fix to resolve the problem, which brings the error of not being able to insert an attachment into the database.
Just rename your file name and make the file name shorter, and that’s it.
Note: This error states that the image could be successfully uploaded to the server but it could not be stored into database. Which means something is wrong with file name and you just have to rename the file name before you try to upload it again.

