I need a script which allows me to enter a url(of downloadable file/s) and the script will take it download and unzip it unto my server without using CPU resources. This is an easy task for anyone with beginner php knowledge and on...
If you want to download files from web remotely to your server, its extremely easy to do. Also if you have cpanel or another control panel then you can extract them easily again. <?php set_time_limit(0); ignore_user_abort(); print "<p>Getting</p>"; exec("wget here comes the url"); print "<p>Done.</p>"; ?> Code (markup): Dont forget to chmod 777 the directory where you put this php file.
If it's such an easy task then you should be able to do it It's not the simplest thing for a beginner to figure out, but since I happen to have written a script that efficiently downloads a file (wget is easy as well but it's only on linux and sadly isn't always installed or accessible). If you want to unzip things, check php.net look for zip_open, zip_read, and zip_close, it's fairly straightforward. function downloadFile($remote, $local){ $file = @fopen($remote, 'r'); if (!$file) return false; $f = @fopen($local, 'w+'); if (!$f) return false; while (!feof($file)) fwrite($f, fread($file, 1024)); return true; } PHP: All you do is downloadFile('http://www.blah.com/file.txt', 'file.txt'); and it downloads the remote file and saves it as file.txt. It's a simple and easy function, enjoy
NO NO NO NO NO Do NOT use wget. And if you WERE to use wget, you'd want to add -O file.name so it saves it as what you want. A lot of webhosts will disable exec or system, and I highly doubt he has a dedicated server on hand, although I could be wrong. You also have to make sure that wget is accessible from php, and that it is installed. It's an easy solution, but it's not an efficient one.