Answer the question
In order to leave comments, you need to log in
Is it possible to fix the php script in this way to download the file?
There is a script
$url = 'http://site.ru/down/file.php'; // URL откуда будем выкачивать
$save_path = __DIR__; // Куда будем складывать файлы
$start = microtime(true); //запуск таймера
for($i=0;$i<=999999;$i++){ // Индетификатор файлов от и до
file_put_contents($save_path.'/'."file_{$i}.png",file_get_contents($url."?id={$i}"));
}
echo 'Время выполнения скрипта: '.(microtime(true) - $start).' сек.'; //вывели время выполнения
Answer the question
In order to leave comments, you need to log in
1) I would like to get the name and type of the file using the basename function and then check whether the file exists and if it exists then skip it.Can.
And if basename does not return a name then use its id as the filename
2) Make the number of threads limited if possibleCan.
3) Pause, otherwise with a large number of files, PHP just stops due to lack of execution time, you have to edit php.ini, but I would like to fix this at the level of the script itselfCan.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question