PHP Script to Download, Upload and Uncompress on FTP is easy with a PHP script. It can download from source, uncompress any thing including WordPresslike CMS. Please take the fact that this is actually not a script providing article, the target of this guide to write a PHP Script to Download, Upload and Uncompress on FTP is to make anyone understand, PHP is not very difficult, many modification can be done as per your need.
Basics you will need to code PHP Script to Download, Upload and Uncompress on FTP
For this guide it is quite obvious that you need a Server with FTP or SFTP access. Shell access is not need. You can use any advanced Text Editor like Gedit. Windows users can also can use Gedit. This is due to the fact they support Syntax Highlighting feature.
Basics for PHP Script to Download, Upload and Uncompress on FTP
The major problem is, many Open Source Project do not have the rightly configured url for download link. For example, WordPress always makes it latest.tar.gz for any version. So practically to get the URL, you have to browse to the official Website and get the URL manually. For WordPress you can download such a ready made php script to Download, Upload and Uncompress on FTP from our guide Automate Uploading and Uzipping WordPress on Rackspace Cloud Sites. This will obviously give you the way how to use it.
If you open Gedit and create a new blank file with the name upload.php then, depending on your configuration / settings, PHP Script will automatically get Syntax Highlighting.
Basic targets to write the PHP Script to Download, Upload and Uncompress on FTP :
- Download it from official URL as compress folder and upload to SFTP. This is actually done by wget in case of Shell.
- Umcompress it. Equivalent to tar -xzvf function in shell.
- Delete the original file, Equivalent to rm with name of the file.
This is how we can do which is simplified from posteet.com/view/1079 :
$url = "http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.2.tar.gz";
// Use the latest url within " marks, you can delete these blue lines
"mediawiki-1.19.2.tar.gz"; // We are using a short name in above line
escapeshellarg($url); exec("wget " . $esc); $shell = "tar -xzvf $file"; //as the file is tar.gz we will use $shell = "unzip $file";
$shell = escapeshellcmd($shell);
$del = “rm $file“;
// We need to delete it $del = escapeshellcmd($del);
exec($del,$nu); // This will show the word Complete at the end of operation
Like This is your gedit :
This PHP Script to Download, Upload and Uncompress on FTP does the work, but its painful to use. We can reduce the pain by using a form action like this to get a HTML. If you can do it, you will see it is very easy, but some people sells them in Code Canyon like website as premium scripts ! PHP itself is free, for this small lines, is it really honors Open Source ?