WordPress media upload issue could not insert attachment into the database

Could not insert attachment into the database.

When ever I try to upload new images from WordPress media it shows me above error.

Please help me why wp database shows this error.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Try the following solutins:

  1. First of all check your WP database size and check whether the size is full according to your hosting provider’s requirement/rule.
  2. Second option, add this line into your wp-config.php:
define('WP_MEMORY_LIMIT', '256M');

Also if you have access to php.ini (or php[version number].ini) file on your server, try to add this line:

memory_limit 512M
  1. By default, some database configs have a collation or charset that doesn’t allow special character. Check whether the file name of the image you’re trying to upload is having any special characters. If so, delete them and use only alphanumeric. Then retry.
  2. Also, please check your folder permission. Read more about it on https://www.wpbeginner.com/wp-tutorials/how-to-fix-image-upload-issue-in-wordpress/

Hope it helps.

Method 2

Auto-increment missing…

Same issue. I’d migrated the site from another server. Found that the Auto-Increment flag was missing from the wp_post table’s ID column. I switched that back on and the problem resolved.

It seems like ALL the tables had lost auto-increment from their ID columns though…. headache!


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x