Ecommerce Shopify WordPress Discussion

How do I send multiple files using PHP Curl

$file_path = ABSPATH . 'wp-content/uploads/2023/11/XXXXX.png'; // API endpoint URL $api_endpoint = 'https://xxxxxx'; // Authentication token $auth_token = 'xxxxxxxx'; // Payload data $data = array( 'body' => 'Test', 'sender' => 'api-test', 'bccRecipients' => 'xxxx@xxxxx.com', 'subject' => 'XXX', 'securityLevel' => 2, 'ServerUrl' => 'XX.COM', ); // Prepare headers $headers = array( 'Content-Type: multipart/form-data', // Use multipart/form-data for file uploads 'x-auth-token: ' . $auth_token, ); // Initialize cURL session $ch = curl_init(); // Prepare the file for upload $file_post = array( 'file' => new CURLFile($file_path), ); // Merge the payload data with the file $post_fields = array_merge($data, $file_post); // Set cURL options curl_setopt($ch, CURLOPT_URL, $api_endpoint); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 45); // Execute cURL session $response = curl_exec($ch); // Check for cURL errors if (curl_errno($ch)) { // Handle the error (return an error message, or an empty string, as per your needs) $error_message = 'cURL Error: ' . curl_error($ch); curl_close($ch); return 'Error: ' . $error_message; } // Close cURL session curl_close($ch); // Return the response return $response; This is the code that I am using to send file from Wordpress, it works fine but the issues I cant seem to figure out how to send 2 files in same request, I tried a lot of ways but it always get corrupted. Any assistance would be appreciated I tried to send file in an array, using different keys but nothign work
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.