PHP CURL: The usage of the @filename API for file uploading is deprecated
php
Solution
The best solution I have found is /src/Guzzle/Http/Message/PostFile.php:
public function getCurlValue()
{
// PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
// See: https://wiki.php.net/rfc/curl-file-upload
if (function_exists('curl_file_create')) {
return curl_file_create($this->filename, $this->contentType, $this->postname);
}
// Use the old style if using an older version of PHP
$value = "@{$this->filename};filename=" . $this->postname;
if ($this->contentType) {
$value .= ';type=' . $this->contentType;
}
return $value;
}
Problem
I got this message: ``` Deprecated: curl_setopt_array(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead ``` I know that I may rewrite my code using `CURLFile` class, but it's awailable only from 5.5. My site must run on PHP 5.3, PHP 5.4 or PHP 5.5, so I can't drop 5.3 and 5.4 compatibility. So I can't use CURLFile. How can I rewrite code to make it run on any PHP without any PHP version checks?