I have a remote download script in which i am using curl to download files <?php $urls=array( 'http://f.askapache.com/mp3/12-lessons-for-those-afraid-of-css.mp3', 'http://f.askapache.com/mp3/27-request-methods-for-use-with-apache-and-rewritecond-and-htaccess.mp3', 'http://f.askapache.com/mp3/301-redirect-with-mod_rewrite-or-redirectmatch.mp3', 'http://f.askapache.com/mp3/404-errorpages.mp3', 'http://f.askapache.com/mp3/503-service-temporarily-unavailable.mp3', 'http://f.askapache.com/mp3/adsense-robots.mp3', 'http://f.askapache.com/mp3/alexa-toolbar-firefox.mp3', 'http://f.askapache.com/mp3/allowing-access-from-1-static-ip-and-deny-the-rest.mp3', 'http://f.askapache.com/mp3/apache-authentication-in-htaccess.mp3'); $save_to='/home/user/public_html/mp3/'; $mh = curl_multi_init(); foreach ($urls as $i => $url) { $g=$save_to.basename($url); if(!is_file($g)){ $conn[$i]=curl_init($url); $fp[$i]=fopen ($g, "w"); curl_setopt ($conn[$i], CURLOPT_FILE, $fp[$i]); curl_setopt ($conn[$i], CURLOPT_HEADER ,0); curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,60); curl_multi_add_handle ($mh,$conn[$i]); } } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); fclose ($fp[$i]); } curl_multi_close($mh); ?> PHP: but the problem is if the browser is closed it effect the downloading of file and downloading become stop so how i use shell_exec command so that if the browser is closed it doesnot effect my downloading? need really help THANKS
i think you should use java here... use shell_exec create a .jar file that will handle all your parameters and will handle the process regardless if browser is closed.
i want to set a script through shell. have you ever use rapishare.com remote upload.. i want exactly like this ..
First, you need to make sure that you have the privilege to run commands in the shell. Second, you need to read the documentation of shell_exec - as you can see, it's quite simple, one parameter is the command string and the return is the output of the command. Third, you need to have enough knowledge in running shell commands. Luckily, all you gotta do is download, this can be done with lwp-download command. With it, you won't need cURL. Try the following: $urls=array( 'http://f.askapache.com/mp3/12-lessons-for-those-afraid-of-css.mp3', 'http://f.askapache.com/mp3/27-request-methods-for-use-with-apache-and-rewritecond-and-htaccess.mp3', 'http://f.askapache.com/mp3/301-redirect-with-mod_rewrite-or-redirectmatch.mp3', 'http://f.askapache.com/mp3/404-errorpages.mp3', 'http://f.askapache.com/mp3/503-service-temporarily-unavailable.mp3', 'http://f.askapache.com/mp3/adsense-robots.mp3', 'http://f.askapache.com/mp3/alexa-toolbar-firefox.mp3', 'http://f.askapache.com/mp3/allowing-access-from-1-static-ip-and-deny-the-rest.mp3', 'http://f.askapache.com/mp3/apache-authentication-in-htaccess.mp3'); foreach($urls as $url) { $output = shell_exec("lwp-download $url"); echo "<pre>$output</pre>"; } PHP: But I'm not sure if it actually finishes all of the download because I'm not sure if PHP is gonna pause and wait for a download to finish, most likely it will. As you can see, PHP goes in a loop and it needs to run the shell command 9 times to download those nine files. So, if the user closes the browser, same thing might happen. I'm not very familiar with shell, but I believe the shell also has a loop command.
Even easier... http://php.net/function.ignore_user_abort EDIT: You might as well want to take a look at set_time_limit - http://php.net/set_time_limit