public static function downloadToFile($url) { $result = HTTPRequest::request($url); if ($result['Status'] == 'OK') { $path = Yii::app()->params['DIR_UPLOAD_ROOT'] . 'data/temp/'; if (!file_exists($path)) { mkdir($path, 0755, true); } $filename = $path . md5($url) . '.png'; file_put_contents($filename, $result['content']); return $filename; } return ''; }