Title: Upload Multiple Media by API
Author: sandeepjainlive
Published: <strong>13 oktobra, 2021</strong>
Last modified: 5 septembra, 2026

---

Search plugins

![](https://ps.w.org/upload-multiple-media-by-api/assets/banner-772x250.png?rev=
2613422)

![](https://ps.w.org/upload-multiple-media-by-api/assets/icon-128x128.png?rev=2613438)

# Upload Multiple Media by API

 By [sandeepjainlive](https://profiles.wordpress.org/sandeepjainlive/)

[Download](https://downloads.wordpress.org/plugin/upload-multiple-media-by-api.1.7.0.zip)

 * [Details](https://sl.wordpress.org/plugins/upload-multiple-media-by-api/#description)
 * [Reviews](https://sl.wordpress.org/plugins/upload-multiple-media-by-api/#reviews)
 * [Development](https://sl.wordpress.org/plugins/upload-multiple-media-by-api/#developers)

 [Support](https://wordpress.org/support/plugin/upload-multiple-media-by-api/)

## Description

Upload multiple images and media files to your WordPress Media Library through a
dedicated REST API endpoint.

Upload Multiple Media by API is designed for headless WordPress, mobile apps, external
applications, frontend frameworks, and custom integrations that need reliable programmatic
media uploads.

Each uploaded file is validated, optionally optimized, checked for duplicates, added
to the WordPress Media Library, and returned with detailed information in the API
response.

### Video Tutorial

Learn how to upload multiple media files through the WordPress REST API:

### Features

 * Upload multiple media files in a single REST API request.
 * REST API endpoint for programmatic media uploads.
 * Authentication support using WordPress Application Passwords.
 * Optional ALT text for each uploaded image.
 * Image optimization with configurable quality.
 * Maximum image width and height controls.
 * Duplicate detection using SHA-256 file hashes.
 * Configure maximum files per request.
 * Configure maximum file size.
 * Configure allowed file types.
 * Attach uploaded media to an existing post.
 * Detailed per-file JSON responses.
 * Works with headless WordPress and custom frontend applications.
 * WordPress Media Library integration.

### REST API

Endpoint:

    ```
    /wp-json/mmbyapi/v1/upload-multiple-images
    ```

Method:

    ```
    POST
    ```

File field:

    ```
    mmbyapi_file_upload[]
    ```

Send multiple files using the same field name.

ALT text field:

    ```
    mmbyapi_alt_texts[]
    ```

ALT text is optional and is matched to uploaded files by array index.

Optional post field:

    ```
    post_id
    ```

Use `post_id` to attach uploaded media to an existing WordPress post.

### Image Optimization

Image optimization can be enabled or disabled from the plugin settings.

When enabled, supported images can be optimized according to the configured quality
and maximum dimensions.

Supported optimization formats:

 * JPEG/JPG
 * PNG
 * WebP

Available settings include:

 * Enable or disable image optimization.
 * Image quality from 10 to 100.
 * Maximum image width.
 * Maximum image height.

Images smaller than the configured maximum dimensions are not enlarged.

The API response includes optimization information for each file, including:

 * Original file size.
 * Optimized file size.
 * Saved bytes.
 * Saved percentage.
 * Final image width.
 * Final image height.

When optimization is disabled, uploaded images are not modified by the optimization
process and the response reports `optimized: false`.

### Authentication

Authentication is optional and is disabled by default for backward compatibility.

When authentication is enabled, API requests must be authenticated and the user 
must have the WordPress `upload_files` capability.

WordPress Application Passwords can be used with the REST API.

For production environments, use HTTPS and authenticated requests rather than exposing
an unrestricted upload endpoint.

Example using cURL:

    ```
    curl -X POST "https://example.com/wp-json/mmbyapi/v1/upload-multiple-images" -u "USERNAME:APPLICATION_PASSWORD" -F "mmbyapi_file_upload[]=@image1.jpg" -F "mmbyapi_file_upload[]=@image2.jpg" -F "mmbyapi_alt_texts[]=Front view of the property" -F "mmbyapi_alt_texts[]=Interior of the property"<h3>JavaScript Example</h3>
    const formData = new FormData();

    formData.append('mmbyapi_file_upload[]', file1);
    formData.append('mmbyapi_file_upload[]', file2);

    formData.append(
        'mmbyapi_alt_texts[]',
        'Front view of the property'
    );

    formData.append(
        'mmbyapi_alt_texts[]',
        'Interior of the property'
    );

    const response = await fetch(
        'https://example.com/wp-json/mmbyapi/v1/upload-multiple-images',
        {
            method: 'POST',
            headers: {
                Authorization: 'Basic ' + btoa(
                    'USERNAME:APPLICATION_PASSWORD'
                ),
            },
            body: formData,
        }
    );

    const result = await response.json();
    console.log(result);<h3>Response</h3>
    ```

Successful requests return per-file information including:

 * Attachment ID.
 * Media URL.
 * MIME type.
 * File size.
 * Image dimensions when available.
 * Content hash.
 * Duplicate status.
 * ALT text when provided.
 * Image optimization information when applicable.

Example:

    ```
    {
        "success": true,
        "total": 2,
        "uploaded": 2,
        "failed": 0,
        "duplicates": 0,
        "post_id": null,
        "files": [
            {
                "file": "image1.jpg",
                "success": true,
                "duplicate": false,
                "attachment_id": 123,
                "url": "https://example.com/wp-content/uploads/2026/09/image1.jpg",
                "mime_type": "image/jpeg",
                "title": "image1",
                "filesize": 100785,
                "width": 2560,
                "height": 1920,
                "hash": "sha256-file-hash",
                "optimization": {
                    "optimized": true,
                    "original_size": 233292,
                    "optimized_size": 100785,
                    "saved_bytes": 132507,
                    "saved_percent": 56.8,
                    "width": 2560,
                    "height": 1920
                },
                "alt_text": "Front view of the property"
            }
        ]
    }
    ```

If some files succeed while others fail, the endpoint returns HTTP 207 and provides
a result for each file.

### Duplicate Detection

Duplicate detection is enabled by default and uses a SHA-256 content hash.

The plugin calculates a SHA-256 hash of each uploaded file and stores the hash as
attachment metadata. If identical file content is uploaded again, the existing Media
Library attachment is returned instead of creating another attachment.

Renaming a file does not bypass duplicate detection because the check is based on
file content.

### Admin Settings

The plugin provides settings for:

 * Authentication requirements.
 * Maximum files per request.
 * Maximum file size.
 * Allowed file types.
 * Duplicate detection.
 * Image optimization.
 * Image quality.
 * Maximum image width.
 * Maximum image height.

These settings help administrators control external media uploads and image processing.

### Use Cases

 * Headless WordPress media uploads.
 * Next.js and React applications.
 * Mobile applications.
 * Custom frontend applications.
 * External systems integrating with WordPress.
 * Bulk image uploads.
 * Property and real estate websites.
 * Product and catalog management systems.
 * Automated media ingestion workflows.

### Compatibility

 * WordPress 5.0 or higher.
 * PHP 5.6 or higher.
 * WordPress REST API.
 * WordPress Media Library.
 * JPEG/JPG, PNG, GIF, and WebP according to the configured MIME allow-list.

## Screenshots

[⌊Configure authentication, upload limits, allowed file types, duplicate detection,
and image optimization settings.⌉⌊Configure authentication, upload limits, allowed
file types, duplicate detection, and image optimization settings.⌉[

Configure authentication, upload limits, allowed file types, duplicate detection,
and image optimization settings.

[⌊Upload multiple media files with individual ALT text and receive detailed optimization
and upload information in the JSON response.⌉⌊Upload multiple media files with individual
ALT text and receive detailed optimization and upload information in the JSON response
.⌉[

Upload multiple media files with individual ALT text and receive detailed optimization
and upload information in the JSON response.

## FAQ

### Can I upload multiple files in one request?

Yes. Add multiple files using the `mmbyapi_file_upload[]` field.

### Can I provide ALT text for uploaded images?

Yes. Use the optional `mmbyapi_alt_texts[]` field. ALT text is matched to files 
by array index.

### Can I optimize uploaded images?

Yes. Enable Image Optimization in the plugin settings and configure the desired 
quality and maximum dimensions.

### Will images be enlarged?

No. The maximum width and height settings are used to limit oversized images. Smaller
images are not enlarged by the optimization process.

### Can I disable image optimization?

Yes. Image optimization can be disabled from the plugin settings.

### Does the plugin detect duplicate files?

Yes. Duplicate detection uses a SHA-256 content hash to identify matching files.

### Can I attach media to a post?

Yes. Provide the optional `post_id` field with the ID of the existing WordPress 
post.

### Does the plugin require authentication?

No. Authentication is optional and disabled by default for backward compatibility.
For production environments, authenticated uploads are recommended.

### What happens if some files fail?

The API returns a result for each file. When a request contains both successful 
and failed uploads, the endpoint returns HTTP 207.

### Does the plugin work with headless WordPress?

Yes. The REST API makes it suitable for headless WordPress, Next.js, React, mobile
apps, and other external applications.

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“Upload Multiple Media by API” is open source software. The following people have
contributed to this plugin.

Contributors

 *   [ sandeepjainlive ](https://profiles.wordpress.org/sandeepjainlive/)

[Translate “Upload Multiple Media by API” into your language.](https://translate.wordpress.org/projects/wp-plugins/upload-multiple-media-by-api)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/upload-multiple-media-by-api/),
check out the [SVN repository](https://plugins.svn.wordpress.org/upload-multiple-media-by-api/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/upload-multiple-media-by-api/)
by [RSS](https://plugins.trac.wordpress.org/log/upload-multiple-media-by-api/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.7.0

 * Added Image Optimization with configurable quality and maximum dimensions.
 * Added optimization statistics to the REST API response.
 * Added support for per-file ALT text through the REST API.
 * Improved REST API upload response details.
 * Updated documentation for image optimization and ALT text.

#### 1.6.1

 * Added optional ALT text support for uploaded images.
 * Added per-image ALT text support through the REST API.
 * Included ALT text in per-file API responses.

#### 1.6.0

 * Added optional REST API authentication.
 * Added admin settings page.
 * Added upload_files capability check.
 * Added detailed per-file API responses.
 * Added duplicate detection using a content hash.
 * Added maximum files per request setting.
 * Added maximum file size setting.
 * Added allowed MIME type settings.
 * Added optional post_id support.
 * Preserved the existing endpoint and field name.

#### 1.5.1

 * Fixed multiple-file handling for multipart/form-data requests.
 * Improved upload error handling.

## Meta

 *  Version **1.7.0**
 *  Last updated **1 dan ago**
 *  Active installations **10+**
 *  WordPress version ** 5.0 or higher **
 *  Tested up to **7.1**
 *  PHP version ** 5.6 or higher **
 *  Language
 * [English (US)](https://wordpress.org/plugins/upload-multiple-media-by-api/)
 * Tags
 * [file upload](https://sl.wordpress.org/plugins/tags/file-upload/)[Headless WordPress](https://sl.wordpress.org/plugins/tags/headless-wordpress/)
   [media upload](https://sl.wordpress.org/plugins/tags/media-upload/)[multiple upload](https://sl.wordpress.org/plugins/tags/multiple-upload/)
   [rest-api](https://sl.wordpress.org/plugins/tags/rest-api/)
 *  [Advanced View](https://sl.wordpress.org/plugins/upload-multiple-media-by-api/advanced/)

## Ratings

No reviews have been submitted yet.

[Your review](https://wordpress.org/support/plugin/upload-multiple-media-by-api/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/upload-multiple-media-by-api/reviews/)

## Contributors

 *   [ sandeepjainlive ](https://profiles.wordpress.org/sandeepjainlive/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/upload-multiple-media-by-api/)