0

I am trying to import demo content in my installed theme, but every time I try to import data by uploading the XML/JSON file, it throws an error.

I get this error while trying to import a widget file from the Tools->Widget Importer and Exports->uploading a .wie file.

enter image description here

I get this error while uploading demo content through a plugin One Click Demo Import.

enter image description here

It has two option

  1. Is click on upload button and then it automatically uploads the files.

  2. Is to uploading files manually (XML,JSON files).

When I do 2nd option, it sometimes gives a success message, but no changes reflect in theme or anywhere (If the data imports successfully, it creates demo pages which shows in Pages menu[worked on localhost]).

I am having this issue on the server (AWS Linux 2), everything is working fine on localhost. I have made some changes in the php.ini file also but didn't work (changed default values with this values).

upload_max_filesize (256M)
max_input_time (300)
memory_limit (256M)
max_execution_time (300)
post_max_size (512M)

Please suggest what else I can try.

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
Anukool
  • 732
  • 1
  • 9
  • 21
  • Are you able to add new plugins from wp plugin page or able to upload new images to the media library? – Krishnadas PC Oct 18 '18 at 05:30
  • 1
    this might be a permission issue. Can you check the group and owner of the uploads folder? – Omar Tanti Oct 18 '18 at 05:44
  • no, both the things are not working, showing error. "Installation failed" at the time of installation of a plugin and "The uploaded file could not be moved to wp-content/uploads/2018/10." while uploading media. – Anukool Oct 18 '18 at 05:47
  • group : ec2-user , owner: ec2-user and directory permission : 775 (octal: 0775. I really dont know what this 0 means before 777,this is showing in my FTP client) – Anukool Oct 18 '18 at 05:48

1 Answers1

0

This problem can have many causes.

First, do you have enough space in your server?

Second, can be due to wrong permissions in the wp-content. In order to fix it, recursively change group permissions of the folders and sub-folders of wp-content to enable write permissions and change file permissions to 664.

If you're using FileZilla, just FTP to that server, right click in the folder, go to permissions and set it to 775 and apply recursively to subdirectories only. For the files, make sure they have 664 by recursively changing the permissions of files only.

If you want to use a terminal, inside of wp-content:

find . -type d -exec chmod -R 775 {} \;

find . -type f -exec chmod -R 664 {} \;

Thirdly, If you still see the error, then you will need to empty the temporary files directory.

WordPress uploads your images using PHP which first saves the uploads to a temporary directory on your web server. After that it moves them to your WordPress uploads folder.

If this temporary directory is full or is poorly configured, then WordPress will not be able to write the file to disk.

If you have no idea where to find this folder, check: https://developer.wordpress.org/reference/functions/get_temp_dir/ . This method will allow you to reach that location. You can also check 'upload_tmp_dir' in php.ini.

If no location is defined (which is very unlikely) you need to paste this code to the wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging’.

define('WP_TEMP_DIR', dirname(__FILE__) . '/wp-content/temp/');

Next, you need to go to wp-content/ folder and create a new folder inside it. You need to name this new folder temp.

Fourthly, check this other answer on stack: https://stackoverflow.com/a/16091596/5675325

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
  • still not working. getting the same error : "The uploaded file could not be moved to wp-content/uploads/2018/10." @tiagoperes – Anukool Oct 18 '18 at 06:18
  • still not working after giving 664 to files, i have gave this permissions earlier but didn't work. @tiagoperes – Anukool Oct 18 '18 at 06:28
  • Did you go through the 3 checks mentioned and the problem remains? – Tiago Martins Peres Oct 18 '18 at 06:31
  • for the third point, i don't have any field like that, in fact there is no such text field or option like that. all i can see is : **1** Image Sizes heading which includes 1. thumbnail size, 2. medium size, 3. large size, with height and width fields and **2** is Uploading Files Heading which has a check box with this "Organize my uploads into month- and year-based folders" @tiagoperes – Anukool Oct 18 '18 at 06:39
  • Check what was now written – Tiago Martins Peres Oct 18 '18 at 06:43
  • i am new to this, can you please help me out how can i fix this? which settings i need to change or any suggestion where i can get this information.@tiagoperes – Anukool Oct 18 '18 at 06:46
  • hii @tiagoperse, i have checked php.ini file and this variable : "upload_tmp_dir" is commented, so i have pasted the code in wp-config.php as you suggested but still not able to upload files, do i need to uncomment this variable in php.ini file also to make things work? – Anukool Oct 22 '18 at 04:58
  • Did you also create the folder as I said? – Tiago Martins Peres Oct 22 '18 at 08:18
  • Yes i created the folder. – Anukool Oct 22 '18 at 08:20
  • Then uncomment the variable in php.ini. Then I suggest you also restart apache before testing to ensure the changes take place. – Tiago Martins Peres Oct 22 '18 at 08:28
  • Hii @tiagoperse, sorry for the inconveniences but i just found that the changes I made in php.ini file are not reflecting. I did phpinfo() to check other details but i found that the property values i changed are still the default values but they are changed in ini file. Can you please explain what happened here? – Anukool Oct 22 '18 at 09:01
  • If your php.ini doesn't have any errors, do: sudo service apache2 restart – Tiago Martins Peres Oct 22 '18 at 09:07
  • Ensure you have this line commented: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED in php.ini – Tiago Martins Peres Oct 22 '18 at 09:08
  • I restarted the apache every time i made changes in php.ini file but nothing reflected, then i tried this : sudo systemctl restart php-fcm and it throwed an error and now the server is not working. – Anukool Oct 22 '18 at 09:12
  • Do you have a written procedure with all steps you've done to configure the server and install wp in it? – Tiago Martins Peres Oct 22 '18 at 09:18
  • i have followed this documentation to install LAMP [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html] and this for installing wordpress [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html] – Anukool Oct 22 '18 at 09:23
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/182254/discussion-between-anukool-and-tiagoperes). – Anukool Oct 22 '18 at 09:30