Added new example

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@256363 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Felipe Pena 2008-03-30 17:04:01 +00:00
parent 7811270746
commit e62dfa2836

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.28 $ -->
<!-- $Revision: 1.29 $ -->
<refentry xml:id="function.curl-setopt" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>curl_setopt</refname>
@ -1142,9 +1142,7 @@
&reftitle.examples;
<para>
<example>
<title>
Initializing a new cURL session and fetching a web page
</title>
<title>Initializing a new cURL session and fetching a web page</title>
<programlisting role="php">
<![CDATA[
<?php
@ -1165,6 +1163,54 @@ curl_close($ch);
</programlisting>
</example>
</para>
<para>
<example>
<title>Uploading file</title>
<programlisting role="php">
<![CDATA[
<?php
/* http://localhost/upload.php:
print_r($_POST);
print_r($_FILES);
*/
$ch = curl_init();
$data = array('name' => 'Foo', 'file' => '@/home/user/test.png');
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[name] => Foo
)
Array
(
[file] => Array
(
[name] => test.png
[type] => image/png
[tmp_name] => /tmp/phpcpjNeQ
[error] => 0
[size] => 279
)
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">