I want to download multiple files (at the same time) from array of urls in php
Example :
$array = array(
"http://mysite.com/a1.zip",
"http://mysite.com/a2.zip",
"http://mysite.com/a3.zip",
"http://mysite.com/a4.zip",
"http://mysite.com/a5.zip"
);
I want to download above mentioned file to the below mentioned path without using foreach i want to download them simultaneously in php..
$to_file_path = "http://www.mysite.com/downloaded";
if($to_file_path)
///it should return after copying all the files to the new path
echo 'successful';
i was sure that curl can do this but please anybody create some simple example for me bcoz i am not very much familiar with curl..
Please a little help will be appreciated..
Hey it is not actually duplicate, my logic is far different i want to download multiple files at a same time without waiting one file to complete this way we can utilize the full power of server and it can save our time.. kindly help me.. i badly need this..
i can download it one by one with
foreach($array as $filename){
copy($filename,$to_file_path.basename($filename))
}
but it sucks so much time it download each file seperately but i want to download all the files mentioned in the array simultaneously..
Please Help.. a sample coding in comment is appreciated.. Thanks