1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<!-- $Revision$ -->
3
- <!-- EN-Revision: af024f48002338a9543b6a7f3e98fdbc14388d8b Maintainer: takagi Status: ready -->
3
+ <!-- EN-Revision: 2b5457cc2db9d5776fba796a9a89227c890a9d52 Maintainer: takagi Status: ready -->
4
4
<!-- Credits: mumumu -->
5
5
6
6
<refentry xml : id =" curlfile.construct" xmlns =" http://docbook.org/ns/docbook" xmlns : xlink =" http://www.w3.org/1999/xlink" >
@@ -174,15 +174,12 @@ array(1) {
174
174
<?php
175
175
$request = curl_init('http://www.example.com/upload.php');
176
176
curl_setopt($request, CURLOPT_POST, true);
177
- curl_setopt($request,
178
- CURLOPT_SAFE_UPLOAD, true); curl_setopt(
179
- $request,
180
- CURLOPT_POSTFIELDS,
181
- [
182
- 'blob[0]' => new CURLFile(realpath('first-file.jpg'), 'image/jpeg'),
183
- 'blob[1]' => new CURLFile(realpath('second-file.txt'), 'text/plain'),
184
- 'blob[2]' => new CURLFile(realpath('third-file.exe'), 'application/octet-stream'),
185
- ] );
177
+ curl_setopt($request, CURLOPT_SAFE_UPLOAD, true);
178
+ curl_setopt($request, CURLOPT_POSTFIELDS, [
179
+ 'blob[0]' => new CURLFile(realpath('first-file.jpg'), 'image/jpeg'),
180
+ 'blob[1]' => new CURLFile(realpath('second-file.txt'), 'text/plain'),
181
+ 'blob[2]' => new CURLFile(realpath('third-file.exe'), 'application/octet-stream'),
182
+ ]);
186
183
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
187
184
188
185
echo curl_exec($request);
@@ -199,14 +196,12 @@ curl_close($request);
199
196
// procedural
200
197
$request = curl_init('http://www.example.com/upload.php');
201
198
curl_setopt($request, CURLOPT_POST, true);
202
- curl_setopt($request, CURLOPT_SAFE_UPLOAD, true); curl_setopt(
203
- $request,
204
- CURLOPT_POSTFIELDS,
205
- [
206
- 'blob[0]' => curl_file_create(realpath('first-file.jpg'), 'image/jpeg'),
207
- 'blob[1]' => curl_file_create(realpath('second-file.txt'), 'text/plain'),
208
- 'blob[2]' => curl_file_create(realpath('third-file.exe'), 'application/octet-stream'),
209
- ] );
199
+ curl_setopt($request, CURLOPT_SAFE_UPLOAD, true);
200
+ curl_setopt($request, CURLOPT_POSTFIELDS, [
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
+ ]);
210
205
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
211
206
212
207
echo curl_exec($request);
0 commit comments