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.
Related Posts:
- How to register images uploaded via FTP in media library?
- WordPress media upload “HTTP error”
- How to upload a media file via FTP and then create an attachment post with it?
- Adding a querystring to an image URL when clicking ‘insert into post’?
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- zip unzip attachments in wordpress
- Change image data durgin upload
- Upload images from one server to an other in wordpress
- Renaming “Expand Details” within “Add Media”
- Edit Image/Image Details – Replace button missing
- Changing upload directory temporarily
- How to change upload directory in wp_handle_upload
- Remove “Insert from URL” link in Media upload – WP 3.5
- Decrease file size upload in Media
- Adding a custom image upload size and making it selected by default?
- Hide custom image sizes from media library
- Hide old attachments from wp media library
- Image Upload “exceeds the maximum upload size for this site”, but php.ini is correct
- Failed media upload: “The uploaded file was only partially uploaded.”
- Create Image Uploader for Widget
- Debugging upload problem: What part of WP does actual image-resizing?
- How to resize image on client-side before upload?
- How to upload imagick resource to media in wordpress
- Accessing a random image via ajax
- Make WordPress upload directory outside wordpress root with custom url
- Is it unsafe to put php in the /wp-content/uploads directory?
- Adding featured image via PHP
- How to enlarge the media file upload size in wordpress admin
- Restrict WordPress File Type Uploads by User Type
- File upload, uploads only file name
- Modify Maximum upload file size text
- How to import 55k images (uploaded via FTP) into WordPress Media libary? [closed]
- Upload a json file in php [closed]
- Custom image upload
- wp_handle_upload – The uploaded file could not be moved to wp-content/uploads/2012/09
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- Memory errors with media upload, WordPress can’t use more than 96M (while there’s 512 available!)
- Get most recent media upload
- Convert all images to PNG on file upload
- Upload Image in a WordPress page using PHP
- WordPress (3.9.1) MultiSite Permissions. Is chown the answer?
- How do the pros code up a WordPress theme? Locally? Through FTP?
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- how to retrieve uploaded url of zip files
- Why is $_REQUEST an empty array in admin-ajax.php?
- wordpress media library new uploads don’t write to database
- Need help with Google drive API [closed]
- Upload file could not be moved to wp-content/uploads
- Change WordPress Upload Folder using wp handle upload
- How do I Import / Upload Files with jQuery AJAX?
- Redirect to another page using contact form 7? [closed]
- WordPress automatically adds links to uploaded images
- Can I get an email notification when media is uploaded to the media library?
- Blob file download problem
- How to remap one of the TinyMCE Advanced Editor button to open the wordpress media library?
- WordPress upload file size error even after raising php limits
- Get uploaded image and attach it to the new post
- Get featured image with custom size outside WordPress
- Why is my max_upload_filesize being limited to 2M? [duplicate]
- Images Uploaded saving onto older/previous year folders
- Convert canvas to image and upload image to server
- How to get the filename from file system and create a download link?
- Custom upload folder
- custom plugin with upload files does not work
- How to Make Thumbnail of Post Stay Animated
- Front end file upload returning wrong attachment url
- Convert all uploaded PNG files to PNG-8 format
- How to decrease the max file upload size without using php.ini or htaccess?
- Help with accessing wp-admin page and resolving error messages
- Some problems in custom widget
- Checking page before applying image restrictions while uploading
- Hook on file upload
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- How can I update WordPress plugins or WordPress itself in all server?
- async upload not working when not logged
- WordPress loading all local images from specific directory?
- The style.php file inside theme-engine folder has other content on FTP
- Using custom php to connect to database blocks wp from accessing galery pictures
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- How to handle a lot of media files in the uploads folder? (+10.000)
- I want url from a file in media using title file
- media_handle_upload fails with gravity form submitted image
- Restrict File Type Uploads by User on Wordress via functions.php
- File path for attachments outside of wp-content/uploads
- Is custom behaviour possible when asynchronously uploading?
- How to resize an image server-side before upload?
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Name Input from widget displays Sidebar name instead of saved data
- show/hide attachments
- File Upload with Server in safe_mode
- Correct Syntax for uploading files to custom directory in WordPress
- Generate and upload screenshot as featured image for user-submitted post
- Pull latest Youtube Video from json url and make new post
- WordPress directories not writable after PHP version upgrade
- Many images in wp-content/uploads folder that are not in Media Library
- I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
- Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?
- Options for using custom PHP in a wordpress site? No FTP access
- Unable to upload media to WordPress