Is there any permanant way to upload images via FTP to WordPress media library other than the available plugins which don't really work well most of the time? I would really appreciate if anyone could help me with this. Sorry I don't know PHP.

Thanks in advance!

  • Hi John, Welcome to WPSE! Can you please elaborate your question? Why can't you just use the media library to upload the images?
    – Johansson
    Jun 27, 2017 at 21:26
  • For photo galleries I have to upload a lot of images and uploading through media library is very slow. It would be way for faster if I could upload the images through ftp. That would help me a lot!
    – John D
    Jun 27, 2017 at 21:33
  • 1
    It is possible to upload automatically, but not via FTP, since the images must also be stored at Database.
    – Johansson
    Jun 27, 2017 at 21:37
  • Benefits of using the media library: you can add alt text immediately, and you can manage those files later. If you upload in FTP your files won't be findable through the media library, and you'll have to manually include alt text as well as all of the responsive image code WP includes on its own. There are a couple of different ways to upload images in media library so I'd encourage you to explore them and find the one that saves you the most time.
    – WebElaine
    Jun 27, 2017 at 21:46

1 Answer 1


You can upload your images to your host, and then use media_sideload_image() to upload each file. Let's assume you upload all of your images to a folder named wpse, in the root of your WordPress installation:

// Set the directory
$dir = ABSPATH .'/wpse';
// Define the file type
$images = glob($directory . "*.jpg");
// Run a loop and upload every file to media library
foreach($images as $image) {
    // Upload a single image
    media_sideload_image($image,'SOME POST ID HERE');

Images must be attached to a post, but you can detach them afterward.

  • 1
    Thanks a lot for all the help! I will try the above mentioned process.
    – John D
    Jun 28, 2017 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.