public function addPostFile($filename)
    {
        if ($filename instanceof UploadedFile) {

            // Get original filename
            $name = $filename->getClientOriginalName();

            // Move the file
            $file = $filename->move(sys_get_temp_dir() . '/' . uniqid(), $name);

            // Get the new file path
            $filename = $file->getRealPath();
        }

        if (!is_readable($filename)) {
            throw new InvalidArgumentException("Unable to open {$filename} for reading");
        }

        // 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($filename);
        }

        // Use the old style if using an older version of PHP
        return "@{$filename}";
    }