You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
712 B
35 lines
712 B
6 years ago
|
<?php
|
||
|
/**
|
||
|
* Created by Error202
|
||
|
* Date: 13.09.2018
|
||
|
*/
|
||
|
|
||
|
namespace core\helpers;
|
||
|
|
||
|
class FileHelper extends \yii\helpers\FileHelper
|
||
|
{
|
||
|
|
||
|
|
||
|
public static function downloadFile($url, $path)
|
||
|
{
|
||
|
$new_file = null;
|
||
|
$new_name = $path;
|
||
|
$file = fopen($url, 'rb');
|
||
|
if ($file) {
|
||
|
$new_file = fopen($new_name, 'wb');
|
||
|
if ($new_file) {
|
||
|
while (!feof($file)) {
|
||
|
fwrite($new_file, fread($file, 1024 * 8), 1024 * 8);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if ($file) {
|
||
|
fclose($file);
|
||
|
}
|
||
|
if ($new_file) {
|
||
|
fclose($new_file);
|
||
|
}
|
||
|
return $new_file ? true : false;
|
||
|
}
|
||
|
}
|