Skip to content

Commit 2b5457c

Browse files
authored
Fix CURLFile multiple files examples (php#1446)
1 parent 317a816 commit 2b5457c

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

reference/curl/curlfile/construct.xml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,12 @@ array(1) {
169169
<?php
170170
$request = curl_init('http://www.example.com/upload.php');
171171
curl_setopt($request, CURLOPT_POST, true);
172-
curl_setopt($request,
173-
CURLOPT_SAFE_UPLOAD, true); curl_setopt(
174-
$request,
175-
CURLOPT_POSTFIELDS,
176-
[
177-
'blob[0]' => new CURLFile(realpath('first-file.jpg'), 'image/jpeg'),
178-
'blob[1]' => new CURLFile(realpath('second-file.txt'), 'text/plain'),
179-
'blob[2]' => new CURLFile(realpath('third-file.exe'), 'application/octet-stream'),
180-
] );
172+
curl_setopt($request, CURLOPT_SAFE_UPLOAD, true);
173+
curl_setopt($request, CURLOPT_POSTFIELDS, [
174+
'blob[0]' => new CURLFile(realpath('first-file.jpg'), 'image/jpeg'),
175+
'blob[1]' => new CURLFile(realpath('second-file.txt'), 'text/plain'),
176+
'blob[2]' => new CURLFile(realpath('third-file.exe'), 'application/octet-stream'),
177+
]);
181178
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
182179
183180
echo curl_exec($request);
@@ -194,14 +191,12 @@ curl_close($request);
194191
// procedural
195192
$request = curl_init('http://www.example.com/upload.php');
196193
curl_setopt($request, CURLOPT_POST, true);
197-
curl_setopt($request, CURLOPT_SAFE_UPLOAD, true); curl_setopt(
198-
$request,
199-
CURLOPT_POSTFIELDS,
200-
[
201-
'blob[0]' => curl_file_create(realpath('first-file.jpg'), 'image/jpeg'),
202-
'blob[1]' => curl_file_create(realpath('second-file.txt'), 'text/plain'),
203-
'blob[2]' => curl_file_create(realpath('third-file.exe'), 'application/octet-stream'),
204-
] );
194+
curl_setopt($request, CURLOPT_SAFE_UPLOAD, true);
195+
curl_setopt($request, CURLOPT_POSTFIELDS, [
196+
'blob[0]' => curl_file_create(realpath('first-file.jpg'), 'image/jpeg'),
197+
'blob[1]' => curl_file_create(realpath('second-file.txt'), 'text/plain'),
198+
'blob[2]' => curl_file_create(realpath('third-file.exe'), 'application/octet-stream'),
199+
]);
205200
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
206201
207202
echo curl_exec($request);

0 commit comments

Comments
 (0)