Created
September 15, 2019 12:18
-
-
Save Sekaiichi/676abafba3f7acc4a0bd6e26333bf498 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
Class Download{ | |
private function downloadFile($title, $link, $saveLink, $folderName, $i) | |
{ | |
ob_start(); | |
$nameOld = $link . $title . $i .'.mp4'; | |
$saveLink = $saveLink . $folderName . '/' . $title . $i .'.mp4'; | |
file_put_contents($saveLink, fopen($nameOld, 'r')); | |
set_time_limit(0); | |
/*header('Connection: Keep-Alive'); | |
header('Content-Description: File Transfer'); | |
header('Content-Type: application/force-download'); | |
header("Content-Disposition: attachment; filename=lesson1"); | |
header('Content-Transfer-Encoding: binary'); | |
header('Expires: 0'); | |
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); | |
header('Pragma: public'); | |
header('Content-Length: ' . filesize($saveLink)); | |
while (ob_get_level()) { | |
ob_end_clean(); | |
} | |
readfile($saveLink);*/ | |
//unlink($saveLink); | |
} | |
private function existFolder($folderName){ | |
if (!is_dir($folderName)){ | |
mkdir($folderName, 0700); | |
return true; | |
} | |
return true; | |
} | |
public function downloadAll($start, $end, $title, $link, $saveLink, $folderName) | |
{ | |
$this->existFolder($folderName); | |
for ($i = $start; $i < $end; $i++) { | |
$this->downloadFile($title, $link, $saveLink, $folderName, $i); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment