@@ -869,11 +869,10 @@ curl_close($ch);
869869$signedUrl = $data[ 'attributes'] [ 'url' ] ;
870870
871871// Step 2: Upload multiple files
872- // Note: PHP's cURL doesn't support multiple values for the same field name
873- // in the same way as other languages. Each file needs to be uploaded
874- // separately or use a custom multipart body builder.
872+ // Note: PHP cURL limitation - cannot use the same field name multiple times
873+ // in an associative array. Common workarounds:
875874
876- // Option 1: Upload files one by one
875+ // Option 1: Multiple separate uploads (most reliable)
877876foreach ($filePaths as $filePath) {
878877 $ch = curl_init();
879878 curl_setopt($ch, CURLOPT_URL, $signedUrl);
@@ -896,32 +895,13 @@ foreach ($filePaths as $filePath) {
896895
897896echo "Files uploaded successfully\\ n";
898897
899- // Option 2: Use Guzzle for better multipart support
900- // composer require guzzlehttp/guzzle
898+ // Option 2: Check if your panel accepts array notation
899+ // Some implementations may accept files [ 0 ] , files [ 1 ] , etc.
901900/*
902- use GuzzleHttp\\ Client;
903- use GuzzleHttp\\ Psr7;
904-
905- $client = new Client();
906-
907- // Get signed URL (same as above)...
908-
909- $multipart = [ ] ;
910- foreach ($filePaths as $filePath) {
911- $multipart[ ] = [
912- 'name' => 'files',
913- 'contents' => Psr7\\ Utils::tryFopen($filePath, 'r'),
914- 'filename' => basename($filePath)
915- ] ;
901+ $postFields = [ 'directory' => $directory] ;
902+ foreach ($filePaths as $index => $filePath) {
903+ $postFields[ "files[ {$index}] "] = new CURLFile($filePath);
916904}
917- $multipart[ ] = [
918- 'name' => 'directory',
919- 'contents' => $directory
920- ] ;
921-
922- $response = $client->post($signedUrl, [
923- 'multipart' => $multipart
924- ] );
925905* /
926906?>`
927907 }}
0 commit comments