Send string starts with "@" in php curl as string Send string starts with "@" in php curl as string curl curl

Send string starts with "@" in php curl as string


I have found the solution here:http://php.net/manual/en/function.curl-setopt.php

CURLOPT_SAFE_UPLOAD

TRUE to disable support for the @ prefix for uploading files in CURLOPT_POSTFIELDS, which means that values starting with @ can be safely passed as fields. CURLFile may be used for uploads instead.

Added in PHP 5.5.0 with FALSE as the default value. PHP 5.6.0 changes the default value to TRUE.

    $url_str = $url->getUrl();    $ch = curl_init();    curl_setopt($ch, CURLOPT_SAFE_UPLOAD, TRUE); //<- HERE    curl_setopt($ch, CURLOPT_URL, $url_str);    curl_setopt($ch, CURLOPT_POST, count($fields));    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:multipart/form-data']);    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);    $out = curl_exec($ch);    curl_close($ch);