Skip to main contentSkip to footer

Attachment file content cannot be saved

The Relevanssi error “Could not save the file content to the custom field” means that Relevanssi has managed to read the attachment contents but cannot save them to the _relevanssi_pdf_content custom field Relevanssi uses to store the attachment contents. Relevanssi uses the update_post_meta() function to save the content, and for some reason, that function is not accepting the custom field data.

In these cases, the first thing to check is the database collation for the meta_value field in the wp_postmeta database table. The document may contain characters your database table cannot accept. Before WordPress 4.2, the default collation for the databases used utf8 characters. Since 4.2, the collations have used utf8mb4 characters. It’s not unusual that PDF files contain characters that WordPress cannot save in a database table with a utf8 collation.

To fix this, you need to change the database collation. You can make this change if you have direct access to the database with phpMyAdmin, Adminer or some other tool. If you don’t know anything about databases or don’t have access to the database tables, you need to ask someone else to do this for you.

Here’s what the wp_postmeta table may look like in Adminer:

wp_postmeta database table structure in Adminer

The collation is the “Options” column. Here the table uses the utf8_general_ci collation, which is a utf8 collation and needs to be changed. Change the collation to a matching utf8mb4 collation, which in this case is utf8mb4_general_ci and save the database table:

wp_postmeta database table structure in Adminer

The collation of the meta_key field does not matter.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Italian plurals
A Relevanssi user asked about Italian plurals on the Relevanssi support forums. The best answer is to use the Relevanssi…
Can Relevanssi access content outside WordPress?

…the WordPress sites must be part of the same installation. It’s not possible to search content that exists in another WordPress installation, not even if it’s on the same server. No outside content Relevanssi is heavily dependent on WordPress methods. When getting posts, Relevanssi uses the get_post() function in WordPress…and so on. Those functions cannot access anything outside the WordPress installation, whether it’s another WordPress installation, HTML files or external databases. If you still need this… If you really must have Relevanssi access outside data, there’s one way to achieve that: import the data inside your WordPress installation. Create…Short answer: no. Relevanssi can only access WordPress content. For a longer answer, read on. Only within single WP installation Relevanssi only operates within one WordPress installation. Relevanssi Premium supports multisite searching, where the search can return posts from more than one subsite at once, but even in those cases…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed