@@ -169,15 +169,12 @@ array(1) {
169
169
<?php
170
170
$request = curl_init('http://www.example.com/upload.php');
171
171
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
+ ]);
181
178
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
182
179
183
180
echo curl_exec($request);
@@ -194,14 +191,12 @@ curl_close($request);
194
191
// procedural
195
192
$request = curl_init('http://www.example.com/upload.php');
196
193
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
+ ]);
205
200
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
206
201
207
202
echo curl_exec($request);
0 commit comments