diff --git a/reference/curl/functions/curl-file-create.xml b/reference/curl/functions/curl-file-create.xml index 981aaba0af..85010b6648 100644 --- a/reference/curl/functions/curl-file-create.xml +++ b/reference/curl/functions/curl-file-create.xml @@ -4,7 +4,7 @@ curl_file_create - Create the CURLFile object + Create a CURLFile object @@ -16,11 +16,9 @@ stringpostname - + Creates a CURLFile object, used to upload a file with CURLOPT_POSTFIELDS. - &warn.undocumented.func; - @@ -30,7 +28,7 @@ filename - + Path to the file which will be uploaded. @@ -38,7 +36,7 @@ mimetype - + Mimetype of the file. @@ -46,7 +44,7 @@ postname - + Name of the file. @@ -56,7 +54,68 @@ &reftitle.returnvalues; - + Returns a CURLFile object. + + + + + &reftitle.examples; + + + <function>curl_file_create</function> example + + +*/ + +// Create a cURL handle +$ch = curl_init('http://example.com/upload.php'); + +// Create a CURLFile object +$cfile = curl_file_create('cats.jpg','image/jpeg','test_name'); + +// Assign POST data +$data = array('test_file' => $cfile); +curl_setopt($ch, CURLOPT_POST,1); +curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + +// Execute the handle +curl_exec($ch); +?> +]]> + + &example.outputs; + + + array(5) { + ["name"]=> + string(9) "test_name" + ["type"]=> + string(10) "image/jpeg" + ["tmp_name"]=> + string(14) "/tmp/phpPC9Kbx" + ["error"]=> + int(0) + ["size"]=> + int(46334) + } +} +]]> + + + + + + + &reftitle.seealso; + + + curl_setopt +