Zend_Http_Client::encodeFormData PHP Method

encodeFormData() public static method

Encode data to a multipart/form-data part suitable for a POST request.
public static encodeFormData ( string $boundary, string $name, mixed $value, string $filename = null, array $headers = [] ) : string
$boundary string
$name string
$value mixed
$filename string
$headers array Associative array of optional headers @example ("Content-Transfer-Encoding" => "binary")
return string
    public static function encodeFormData($boundary, $name, $value, $filename = null, $headers = array())
    {
        $ret = "--{$boundary}\r\n" . 'Content-Disposition: form-data; name="' . $name . '"';
        if ($filename) {
            $ret .= '; filename="' . $filename . '"';
        }
        $ret .= "\r\n";
        foreach ($headers as $hname => $hvalue) {
            $ret .= "{$hname}: {$hvalue}\r\n";
        }
        $ret .= "\r\n";
        $ret .= "{$value}\r\n";
        return $ret;
    }