11<?xml version =" 1.0" encoding =" utf-8" ?>
22<!-- $Revision$ -->
3- <!-- EN-Revision: af024f48002338a9543b6a7f3e98fdbc14388d8b Maintainer: takagi Status: ready -->
3+ <!-- EN-Revision: 2b5457cc2db9d5776fba796a9a89227c890a9d52 Maintainer: takagi Status: ready -->
44<!-- Credits: mumumu -->
55
66<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) {
174174<?php
175175$request = curl_init('http://www.example.com/upload.php');
176176curl_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+ ]);
186183curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
187184
188185echo curl_exec($request);
@@ -199,14 +196,12 @@ curl_close($request);
199196// procedural
200197$request = curl_init('http://www.example.com/upload.php');
201198curl_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+ ]);
210205curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
211206
212207echo curl_exec($request);
0 commit comments