admin管理员组

文章数量:1289858

I'm trying to import a JPG to my uploads folder using WP-CLI (macOS). I'm connected to the server, I can update and activate plugins, successfully navigate to all folders, etc.

However, when I run:

wp media import /Users/d.j./Desktop/cat.jpg

I get an error:

Warning: Unable to import file '/Users/d.j./Desktop/cat.jpg'. Reason: File doesn't exist.
Error: No items imported.

The file does exist, it's right on my desktop.

Any ideas as to why I would get this error?

edit: I should add that it works fine when I use my local server.

I'm trying to import a JPG to my uploads folder using WP-CLI (macOS). I'm connected to the server, I can update and activate plugins, successfully navigate to all folders, etc.

However, when I run:

wp media import /Users/d.j./Desktop/cat.jpg

I get an error:

Warning: Unable to import file '/Users/d.j./Desktop/cat.jpg'. Reason: File doesn't exist.
Error: No items imported.

The file does exist, it's right on my desktop.

Any ideas as to why I would get this error?

edit: I should add that it works fine when I use my local server.

Share Improve this question edited Jul 13, 2021 at 20:09 itsjustdj asked Jul 11, 2021 at 19:01 itsjustdjitsjustdj 114 bronze badges 2
  • Possibly you need ~ at the start of your path to find the right directory. – vancoder Commented Jul 12, 2021 at 19:00
  • I also tried ~/Desktop/cat.jpg, and I also dragged the file into the terminal window to make sure the path was correct. – itsjustdj Commented Jul 13, 2021 at 20:08
Add a comment  | 

1 Answer 1

Reset to default 1

I figured it out, with some help. You have to be on the same server where the files are located to use wp media import. The steps are:

  1. Log out of ssh connection
  2. Log into the remote server using sftp
  3. Upload the files using sftp, then log out
  4. Log back in using ssh
  5. Then you can use wp media import

Essentially, ssh is for commands and sftp is for file transfers.

I hope this helps someone else with this issue.

本文标签: wp cliWPCLI media import error