我正在使用此curl类来保存文件 - >
class CurlHelper
{
/**
* Downloads a file from a url and returns the temporary file path.
* @param string $url
* @return string The file path
*/
public static function downloadFile($url, $options = array())
{
if (!is_array($options))
$options = array();
$options = array_merge(array(
'connectionTimeout' => 5, // seconds
'timeout' => 10, // seconds
'sslVerifyPeer' => false,
'followLocation' => false, // if true, limit recursive redirection by
'maxRedirs' => 1, // setting value for "maxRedirs"
), $options); …Run Code Online (Sandbox Code Playgroud)