It is necessary to download files from a remote server to mine, but my hoster has a script time limit (300 s) and a speed of about 100-200 kB / s. The maximum time to download 15-25 MB. You need at least 60. So you need to somehow get it.
Now I did it like this, but the file comes in damaged. What am I doing wrong?

$url = 'site.ru/file.mp4'; $size2=getRemoteFileSize($url);// определяем размер файла, работает нормально. echo $url; $path = 'video.mp4'; $size1=filesize($path)-1; $size=$size1.'-'.$size2; $fp = fopen($path, 'a'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RANGE, $size); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); 
  • As I understand it, you need to use the mode 'ab' (Append / Binary): $ fp = fopen ($ path, 'ab'); - etki
  • What does b do? Google did not give clear answers) Allows you to write byte by byte? .. - Fqyeh29

0