mirror of
https://github.com/php/php-src.git
synced 2026-04-22 15:38:49 +02:00
e727919b97
Add CURLStringFile class which works similarly to CURLFile, but
uploads a file from a string rather than a file. This avoids the
need to create a temporary file, or use of a data:// stream.
Basic usage:
$file = new CURLStringFile($data, 'filename.txt', 'text/plain');
curl_setopt($curl, CURLOPT_POSTFIELDS, ['file' => $file]);
Closes GH-6456.
40 lines
894 B
PHP
40 lines
894 B
PHP
<?php
|
|
|
|
/** @generate-class-entries */
|
|
|
|
class CURLFile
|
|
{
|
|
/** @var string */
|
|
public $name = "";
|
|
/** @var string */
|
|
public $mime = "";
|
|
/** @var string */
|
|
public $postname = "";
|
|
|
|
public function __construct(string $filename, ?string $mime_type = null, ?string $posted_filename = null) {}
|
|
|
|
/** @return string */
|
|
public function getFilename() {}
|
|
|
|
/** @return string */
|
|
public function getMimeType() {}
|
|
|
|
/** @return string */
|
|
public function getPostFilename() {}
|
|
|
|
/** @return void */
|
|
public function setMimeType(string $mime_type) {}
|
|
|
|
/** @return void */
|
|
public function setPostFilename(string $posted_filename) {}
|
|
}
|
|
|
|
class CURLStringFile
|
|
{
|
|
public string $data;
|
|
public string $postname;
|
|
public string $mime;
|
|
|
|
public function __construct(string $data, string $postname, string $mime = "application/octet-stream") {}
|
|
}
|