svn: /phpdoc/ja/trunk/reference/curl/curlfile/ construct.xml
[email protected] (Yoshinari Takaoka)
| Newsgroups | php.doc.ja |
|---|---|
| Message-ID | <[email protected]> |
mumumu Fri, 13 Mar 2020 21:24:00 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=349415
Log:
Fix bug #79378 - Uploading multiple files with CURLFile is not documented
Bug: https://bugs.php.net/79378 (Closed) Uploading multiple files with CURLFile is not documented
Changed paths:
U phpdoc/ja/trunk/reference/curl/curlfile/construct.xml
Modified: phpdoc/ja/trunk/reference/curl/curlfile/construct.xml
===================================================================
--- phpdoc/ja/trunk/reference/curl/curlfile/construct.xml 2020-03-13 21:18:38 UTC (rev 349414)
+++ phpdoc/ja/trunk/reference/curl/curlfile/construct.xml 2020-03-13 21:24:00 UTC (rev 349415)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 349387 Maintainer: takagi Status: ready -->
+<!-- EN-Revision: 349411 Maintainer: takagi Status: ready -->
<!-- Credits: mumumu -->
<refentry xml:id="curlfile.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
@@ -142,6 +142,117 @@
]]>
</screen>
</example>
+ <example>
+ <title><function>CURLFile::__construct</function> で、複数のファイルをアップロードする例</title>
+ <para>&style.oop;</para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$request = curl_init('http://www.example.com/upload.php');
+curl_setopt($request, CURLOPT_POST, true);
+curl_setopt($request,
+CURLOPT_SAFE_UPLOAD, true); curl_setopt(
+ $request,
+ CURLOPT_POSTFIELDS,
+ [
+ 'blob[0]' => new CURLFile(realpath('first-file.jpg'), 'image/jpeg'),
+ 'blob[1]' => new CURLFile(realpath('second-file.txt'), 'text/plain'),
+ 'blob[2]' => new CURLFile(realpath('third-file.exe'), 'application/octet-stream'),
+ ] );
+curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
+
+echo curl_exec($request);
+
+var_dump(curl_getinfo($request));
+
+curl_close($request);
+]]>
+ </programlisting>
+ <para>&style.procedural;</para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// procedural
+$request = curl_init('http://www.example.com/upload.php');
+curl_setopt($request, CURLOPT_POST, true);
+curl_setopt($request, CURLOPT_SAFE_UPLOAD, true); curl_setopt(
+ $request,
+ CURLOPT_POSTFIELDS,
+ [
+ 'blob[0]' => curl_file_create(realpath('first-file.jpg'), 'image/jpeg'),
+ 'blob[1]' => curl_file_create(realpath('second-file.txt'), 'text/plain'),
+ 'blob[2]' => curl_file_create(realpath('third-file.exe'), 'application/octet-stream'),
+ ] );
+curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
+
+echo curl_exec($request);
+
+var_dump(curl_getinfo($request));
+
+curl_close($request);
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+array(26) {
+ ["url"]=>
+ string(31) "http://www.example.com/upload.php"
+ ["content_type"]=>
+ string(24) "text/html; charset=UTF-8"
+ ["http_code"]=>
+ int(200)
+ ["header_size"]=>
+ int(198)
+ ["request_size"]=>
+ int(196)
+ ["filetime"]=>
+ int(-1)
+ ["ssl_verify_result"]=>
+ int(0)
+ ["redirect_count"]=>
+ int(0)
+ ["total_time"]=>
+ float(0.060062)
+ ["namelookup_time"]=>
+ float(0.028575)
+ ["connect_time"]=>
+ float(0.029011)
+ ["pretransfer_time"]=>
+ float(0.029121)
+ ["size_upload"]=>
+ float(3230730)
+ ["size_download"]=>
+ float(811)
+ ["speed_download"]=>
+ float(13516)
+ ["speed_upload"]=>
+ float(53845500)
+ ["download_content_length"]=>
+ float(811)
+ ["upload_content_length"]=>
+ float(3230730)
+ ["starttransfer_time"]=>
+ float(0.030355)
+ ["redirect_time"]=>
+ float(0)
+ ["redirect_url"]=>
+ string(0) ""
+ ["primary_ip"]=>
+ string(13) "0.0.0.0"
+ ["certinfo"]=>
+ array(0) {
+ }
+ ["primary_port"]=>
+ int(80)
+ ["local_ip"]=>
+ string(12) "0.0.0.0"
+ ["local_port"]=>
+ int(34856)
+}
+]]>
+ </screen>
+ </example>
</refsect1>
<refsect1 role="seealso">