Simple server to server file downloader script
About a month ago I wrote a script for my own need. It can download files from another server to your server. I just wrote it for my own purpose and it’s pretty simple and stupid enough. But hey, it works 😉
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<?php if (isset($_POST['sub'])) { if (filter_var($url = $_POST['url'], FILTER_VALIDATE_URL)) { define('UPLOAD_DIR', dirname(__FILE__) . '/files/'); $length = 5120; $handle = fopen($url, 'rb'); $filename = UPLOAD_DIR . substr(strrchr($url, '/'), 1); $write = fopen($filename, 'w'); while (!feof($handle)) { $buffer = fread($handle, $length); fwrite($write, $buffer); } fclose($handle); fclose($write); echo "<h1>File download complete</h1>"; } else { echo "<h2>Invalid url</h2>"; } } ?> <form action="" method="POST"> <p> <label for="url">Url:</label> <input type="text" size="50" name="url" id="url" /> </p> <p> <input type="submit" name="sub" value="download" /> </p> </form> |
This script has a form input field to make the operation simpler. … Continue reading Simple server to server file downloader script