Support

Account

Home Forums ACF PRO json import error: "import file empty"

Solving

json import error: "import file empty"

  • Hi,

    I try to copy a group of fields from one wp installation to another. Both systems running with latest WP & ACF Pro.

    When I try to import the json file I get the error like “import file empty” (using the german “version”).

    Here is the file: http://www.realmaker.de/downloads/acf-export-2015-10-26(2).json

    I tried serveral times.

    I remeber I had the error before and then added the files manually to the other system. But I need the field keys to be equal this time.

    Can somebody help?

    UPDATE:
    I tried the import on another WP installation and it worked! So there must be a problem at the WP System. What can that be?

    Thanks!

    Michael

  • What other plugins do you have running on the site with the problem? Have you tried deactivating any other plugins?

  • Hi John,

    thanks your your reply!

    It seems like the plugins are not the problem. I installed the same on my test system without issues.

    Is it possible that there are some right issues when uploading the json file? Do you know to wich directory the json file is uploaded before the import?

  • the file would be uploaded to whatever the temp folder is on your server/host.

    The error that you are getting. After the file is uploaded ACF does a json_decode() on the contents. This returns null if there is something wrong with the json in the file. The only thing I can think of is that the file is somehow being altered during the upload process, maybe something to do with the host.

    Try uploading the file to your media library if it will let you and then compare it to the original.

    • cziko

    • October 24, 2019 at 6:24 pm

    For those who still struggle with this problem: check if your exported JSON file has BOM marker (it depends on the server whether this marker is added to a file). When the marker is present, import doesn’t work. You can always open file in Notepad (on Windows) and save file with UTF-8 coding (not “UTF-8 with BOM”) – it should work unless your file has some syntax issues.

    • jhard

    • January 28, 2020 at 11:49 pm

    Another potential cause for this issue that I just ran into: open_basedir is in effect and does not include the temporary directory where files are uploaded to by PHP.
    ACF reads the files directly, which fails under those circumstances. I’ve filed a bug report, but temporary solution: just change open_basedir to include whatever sys_temp_dir is set to (usually “/tmp” on linux/unix).

  • So here’s some insight into another part of this glitch.
    I’m running a staging site that has the normal wordpress debug=true on it for develelopmental purposes.
    Right now i have an error showing up in the header of my wp-admin for some other plugin that has update issues.

    But when I do an export of fields from the staging site – to transfer them to the live site – it comes up with an ‘Import file empty.” message.

    So when i look at the json file, the debug error that i had on my staging site is at the top of the json file, meaning its messing the whole file up and won’t upload.

    This is using the latest ACF Pro version, just FYI.

    Weird glitch, but hopefully this helps anyone else out.

    All i had to do is remove the text lines from the json file – up til the first ‘[‘ bracket, and then it would upload fine.

  • For me, the problem was that the JSON file that I was trying to import had a comma where there wasn’t suppose to be. Specifically it was on the last line of the location array. Here’s an example, notice here that there is a comma at the end of the “value” line:

    
    "location": [
       [
          {
             "param": "post_template",
             "operator": "==",
             "value": "components\/logo-heading-cta.php",
          }
       ]
    ],
    

    When I removed that comma, like this:

    
    "location": [
       [
          {
             "param": "post_template",
             "operator": "==",
             "value": "components\/logo-heading-cta.php"
          }
       ]
    ],
    

    Then the JSON file imported without any problem. I noticed this because my text editor showed that the comma there was a syntax error. It seems JSON is specific about not having a comma after the last item in an array.

    Maybe this will be the solution for anyone else trying to find an answer to this problem.

  • I was able to solve the problem in a simple way

    Step-by-step method:
    1. Open the purpose output file with the notepad ++ editor
    2. Go to the encoding menu “encoding > UTF-8 ” select and Save File
    3. Upload the file
    I hope your problem is solved

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.