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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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:
- Log out of ssh connection
- Log into the remote server using sftp
- Upload the files using sftp, then log out
- Log back in using ssh
- 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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0