WordPress Failed to Import Media: What to Do Now?
parallax background

WordPress Failed to Import Media: What to Do Now?

The Best Looking WPML Compatible WordPress Themes
December 17, 2020
WordPress Posting to Facebook Done Automatically
February 11, 2021
The Best Looking WPML Compatible WordPress Themes
December 17, 2020
WordPress Posting to Facebook Done Automatically
February 11, 2021
 

Some users experience problems with import in WordPress and may be looking for help. There are different reasons why WordPress fails to import media.

Sometimes it's because of the XML file size. The limit is 7MB, but users often encounter issues with smaller file uploads.

It can also be due to the PHP memory limit or incorrect file permissions.

Many issues occur when users try to transfer their WordPress site to a new host. Images may not display correctly after the switch, so execute this process with care.

It’s important to understand server limitations and how they process imported data. This enables users to avoid certain errors and prepare the correct file size.

Here are some tips on what to do if WordPress failed to import media. Taking these steps should guarantee a fast and smooth upload.

Repeat XML File Download

 

Sometimes issues occur during XML data export. There is a quick fix worth trying - download the export file again.

Go to: WP-admin » Tools » Export » Download Export File

PHP Memory Limit Increase

 

In some cases, WordPress failed to import media due to the PHP memory limit. This issue will show as an HTTP error.

PHP memory limit determines how much memory one PHP process can use.

The web host can increase this limit. This adjustment will allow users to import the media in the desired size.

Another way to increase the memory limit is by editing the wp-coding file.

First, locate the wp-config.php file. Next, modify the PHP memory limit to 256M by typing the following:

define( 'WP_MEMORY_LIMIT', '256M' );

Sometimes it’s also possible to add the following code in the .htaccess file:

php_value memory_limit 256M

If the hosting package doesn't allow you to use that amount of memory, this will not work.

File and Folder Permissions Modification

 

File permissions are an important aspect of security, but they can also restrict users from making content changes. When the message appears that WordPress failed to import media, try checking these permissions.

Permissions consist of a set of numbers. Each digit determines who can do a certain action.

In other words, the digits show who is authorized to read, run, or modify files hosted on your account.

File permissions may not have caused a problem in the past. However, at times, modifications may occur without the users’ knowledge.

For example, it can happen when a web hosting provider runs an upgrade. This may unexpectedly change file permissions.

If the permission mode doesn't give the user the right to upload a file, the following error may appear:

‘Unable to create directory wp-content/uploads/20../0.. Is its parent directory writable by the server?’

Another common sign of this problem is images disappearing from the media library.

To manage file and folder permissions, connect to the WordPress files using FTP. Open the wp-content folder and select 'uploads'.

Right-click on it and 'File permissions' will display in the menu. The numeric value should be set to 755 for all folders and sub-folders.

 

Right-click on it and 'File permissions' will display in the menu. The numeric value should be set to 755 for all folders and sub-folders.

Next, edit file permissions for all the files in the uploads directory. The value recommended for all files is 644.

If WordPress failed to import media during a demo data upload, you may want to check the following:

 
upload_max_filesize = min 128M
post_max_size = min 128M 
max_input_time above 300
max_input_vars above 5000
safe_mode=off
allow_url_fopen= on

Resize Into Smaller Files

In this process, you will need a basic text editor, such as Notepad, Sublime Text, or Coda. It's useful to know a little about markup codes in order to complete the process correctly.

Here is how to break the file into smaller parts:

You can skip the instruction lines at the beginning. Instead, focus attention on the tag.

Look for the tags, because this is the point where the content starts.

Each new small part needs to start and end with the proper tags, such as shown here:

 
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"...
<channel>
<wp:wxr_version>1.2</wp:wxr_version>
Your 5,000-ish lines of content, starting with <item> and ending with </item>
</channel>
</rss>

Be very careful during this process and make sure to follow the pattern. On each line, the format must always contain ... tags in addition to the tags described above.

The next step is to copy and paste these tags into the top and bottom of each file. It is vital to be diligent and avoid any mistakes, otherwise, the process will not work.

Import Smaller Files

I'm interrupting the article to tell you about BeTheme, the definitive multipurpose theme. If trying to satisfy multiple clients has become more stressful than rewarding, BeTheme is the solution for that.

BeTheme’s selection of hundreds of customizable, responsive pre-built websites is the highlight and a proven stress reducer.

The customizability of the theme makes it a dream come true for its users. There are 4 types of Page Builders that you can use with it: WPBakery, BeBuilder, and Elementor among them.

And now with the Live Builder, it’s even more impressive.

Check out BeTheme and see why our users love it!

The rest of the article is down below.

 

With the data divided into smaller files, it should now be easier to upload them.

To start the import, go to: Tools > Import > WordPress

Disadvantages of the Process

Breaking the file into smaller parts is time-consuming.

 

It is a tedious process. It takes a lot of concentration to divide the data correctly.

It may be necessary to split a file containing tens of thousands of lines into many 5,000-line files. But a smaller size file upload will be quick and smooth.

If not done carefully, there may be problems with metadata.

 

The issue may arise when importing multiple pages with hierarchy.

For example, an error may occur if uploading a part that defines the number of a specific page but it ends before defining the number of the parent page.

In such a case, the command won't go through, because you haven't imported the parent page yet. That relationship is invalid.

WordPress rarely warns users about this mistake. So take great care and make sure to write the commands correctly.

Server Data Process Issue

 

Most servers have a timeout limit. That often causes problems with processing imported data.

The XML file passes into a PHP processor script and the data is then transferred into the database. Each line of the XML file needs to be processed, but most servers don't have the time allowance to finish the action.

The maximum 7MB size for media upload refers to the file. It doesn't allow for the performance and capacity of the server processing the file data.

So although the file size is within the limits, the actual upload may still fail. It's important to keep that in mind as the WordPress system won't send an alert about this issue.

Even 2 MB contains a lot of data for processing. The file may still be too big.

300-400 KB, or 5,000 lines of XML markup, seems to import with no issues.

Smaller size files are easier to upload. So the best technique is to divide the content into multiple parts and import them one by one.

This way users can avoid running into an upload error.

Ending thoughts on possible reasons why WordPress failed to import media

There may be different causes of an upload error. These include the file size and how much data the server needs to process.

The issue could also lie in the file and folder permissions. You may not be authorized to perform the import.

It’s also a good idea to check the PHP memory limit.

This article discussed the most common import problems and presented tips on how to resolve them. But avoiding an upload failure is always better than trying to identify the problem and how to fix it.

Keep in mind the servers’ limits and how it processes data. Smaller size files will always be easier to import.

If you enjoyed reading this article on WordPress failed to import media, you should check out this one about how to fix the currently unable to handle this request error.

We also wrote about a few related subjects like how to fix the WordPress parse error, how to fix the parse error syntax error unexpected, WordPress missed schedule, fixing sorry, this file type is not permitted for security reasons, how to fix the link you followed has expired, how to fix an error occurred while processing this directive and Why WordPress is the Best Platform To Build Your Business or Startup Website.

Albert Ślusarczyk
Albert Ślusarczyk
As the co-creator of Be Theme, I am a strong believer in designing with care and patience. I pour my energy, time & knowledge into perfecting the theme for our 260,000+ customers.