CURLStringFile::__construct
Erstellt ein CURLStringFile-Objekt
&reftitle.description;
public CURLStringFile::__construct
stringdata
stringpostname
stringmime"application/octet-stream"
Erstellt ein CURLStringFile-Objekt, welches zum Upload einer
Datei via CURLOPT_POSTFIELDS verwendet wird.
&reftitle.parameters;
data
Die hochzuladenden Daten.
postname
Der in den Upload-Daten zu verwendende Dateiname.
mime
Der MIME-Typ der Datei (Vorgabe ist application/octet-stream).
&reftitle.examples;
CURLStringFile::__construct-Beispiel
*/
// Erstellt ein cURL-Handle
$ch = curl_init('http://example.com/upload.php');
// Erstellt ein CURLStringFile-Objekt
$cstringfile = new CURLStringFile('test upload contents','test.txt','text/plain');
// POST-Daten hinzufügen
$data = array('test_string' => $cstringfile);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Das Handle ausführen
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