Обновить receiving_big_file.php
This commit is contained in:
@@ -3,4 +3,40 @@
|
||||
/*
|
||||
* Получение больших файлов имитирую браузер
|
||||
*
|
||||
/*
|
||||
* @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;
|
||||
}
|
||||
Reference in New Issue
Block a user