42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Получение больших файлов имитирую браузер
|
|
*
|
|
* @param string $url - Путь к файлу
|
|
* @param string $name- Название скаеваемого файла
|
|
*
|
|
*/
|
|
|
|
function downloadBig($url,$name_file):string{
|
|
|
|
$proxy = '10.13.122.242:8090';
|
|
|
|
if(!file_exists('tmp')) mkdir('tmp');
|
|
|
|
$fp = fopen ('tmp/' . basename($name_file['path']), 'w+');
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($name_file, '', '&'));
|
|
curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_HEADER, false);
|
|
curl_setopt($ch, CURLOPT_FILE, $fp);
|
|
$file = curl_exec($ch);
|
|
$info = curl_getinfo($ch);
|
|
curl_close($ch);
|
|
fclose($fp);
|
|
|
|
if($info['http_code'] == 200){
|
|
|
|
if($file){
|
|
return "tmp/".basename($name_file['path']);
|
|
}
|
|
|
|
}else{
|
|
setLog("Error","Ошибка получения от ВП",$info);
|
|
}
|
|
|
|
return false;
|
|
} |