How to Bulk Upload Media Files Using WordPress CLI

Most hosting providers set a maximum file upload in WordPress ranging from 2 to 64MB. This is a huge restriction especially when you want to upload a lot of large files. Even if you manage to increase the upload size limit, big GIF and video files often cause timeout error when uploading through WordPress media library.

In this article, we will show how you can easily upload multiple file attachments from your local files directly to your WordPress media library using WordPress CLI.

1. Use SCP command to securely transfer files

To copy an entire directory from one host to another, use the r switch and specify the destination directory. In this example, we upload all files on Downloads to the sever’s root/Tool folder:

scp -v -r ~/Downloads root@

2. In the remote server, install wp-cli:

Under /root/Tool folder, run these 2 commands:

curl -O
chmod +x wp-cli.phar


3. Use WP-CLI to upload all media files in the Downloads folder

Under /root/Tool folder, run this command:

./wp-cli.phar media import ./Downloads/* --path=/home/pda/webapps/

--path=<path>: Path to the root folder of your WordPress site


That’s all. Now all your files should be imported inside your WordPress media library.