diff --git a/receiving_big_file.php b/receiving_big_file.php index f142676..5e12b33 100644 --- a/receiving_big_file.php +++ b/receiving_big_file.php @@ -3,4 +3,40 @@ /* * Получение больших файлов имитирую браузер * -/* \ No newline at end of file +* @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; + } \ No newline at end of file