CURLStringFile::__construct
Create a CURLStringFile object
&reftitle.description;
public CURLStringFile::__construct
stringdata
stringpostname
stringmime"application/octet-stream"
Creates a CURLStringFile object, used to upload a file with CURLOPT_POSTFIELDS.
&reftitle.parameters;
data
The contents to be uploaded.
postname
The name of the file to be used in the upload data.
mime
MIME type of the file (default is application/octet-stream).
&reftitle.examples;
CURLStringFile::__construct example
*/
// Create a cURL handle
$ch = curl_init('http://example.com/upload.php');
// Create a CURLStringFile object
$cstringfile = new CURLStringFile('test upload contents','test.txt','text/plain');
// Assign POST data
$data = array('test_string' => $cstringfile);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Execute the handle
curl_exec($ch);
?>
]]>
&example.outputs;
array(5) {
["name"]=>
string(8) "test.txt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
string(14) "/tmp/phpTtaoCz"
["error"]=>
int(0)
["size"]=>
int(20)
}
}
string(20) "test upload contents"
]]>
&reftitle.seealso;
curl_setopt