Skip to content

Instantly share code, notes, and snippets.

@santosh
Last active December 10, 2015 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santosh/4467450 to your computer and use it in GitHub Desktop.
Save santosh/4467450 to your computer and use it in GitHub Desktop.
PHP: A PHP script to download files directly download files to webserver. This can help prevent your bandwidth of both end user and the webserver in situations like downloading WordPress to your computer then uploading to server. [Its just the case, WordPress like scripts are already included in some hosting plans ;)].
<?php
/*
Please make sure that you already create a file that you are setting in $saveas variable,
and set its permission to 777 else you can receive an error telling you like permission
denied etc.
*/
// file to open and save to
$saveas = "capitalizr.py.zip";
// file to be downloaded
$fileToDownload = file_get_contents("https://github.com/santosh/capitalizr.py/archive/master.zip");
// the main stuff
file_put_contents($saveas, $downloadThis);
// yes, I have missed the ending PHP bracket and its not a fault, see the link below:
// http://framework.zend.com/manual/1.12/en/coding-standard.php-file-formatting.html#coding-standard.php-file-formatting.general
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment