Posts

Showing posts with the label php

Extract compress files on Server using PHP

Hey All, Sometimes we need to upload large files and folders to server and it takes long time to complete. To make this process faster and simpler you can uncompress the files using one line of code using PHP. <? exec("gunzip -x filename.zip"); ?> You first need to upload the zip on server, make sure to give proper path in PHP code.  You can also compress Server files using below command. <? exec("zip -x filename.zip  Foldername"); ?> Please note, execution of above code tested on PHP running on Linux / Unix Server.

PHP : Get Current Page URL

Below is the PHP code snippest to get Current page URL.need to use $_SERVER array to get the server information. $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":". $_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"] } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } echo $pageURL;