Category Archive: PHP Tips

PHP – Create directory

PHP – Create directory $restna=”100001″; function FtpMkdir($path, $newDir) { $server=’ftp.doubledots.com’; // ftp server $connection = ftp_connect($server); // connection // login to ftp server $user = “me”; $pass = “pass”; $result = ftp_login($connection, $user,… Read More

PHP – File Upload

PHP – File Upload $uploaddir = ‘images/Restaurant/’.$restna.’/’; $uploadfile = $uploaddir . $_FILES['userfile']['name']; echo($uploadfile); print “<pre>”; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { $msg=”File Uploaded Successfully”; } else { $msg=”File Uploaded Faild! <br>Please try again” ; }… Read More

PHP – Image Resize

PHP – Image Resize // Config Options $method = “gd2″;                 // Which method you wish to use to generate the thumbnail // only GD1 and GD2 are spported. $new_size = “128″;               // Width… Read More

Image handling| list image folder – PHP

Image handling| list image folder – PHP <?php $imgdir = ‘/public_html/logs/’; // the directory, where your images are stored $allowed_types = array(‘png’,’jpg’,’jpeg’,’gif’); // list of filetypes you want to show $dimg = opendir($imgdir);… Read More

Move / Rename File

Move / Rename File <?php rename(“/tmp/tmp_file.txt”, “/home/user/login/docs/my_file.txt”); ?>

Create Folder Using PHP

Create Folder Using PHP mkdir(“Documents”, 0700);

Directory lister

Directory lister Description Displays a hyperlinked list of all the files contained in a specified folder. A really simple way to have your own directory browser, just drop the file in the folder… Read More

Random image

Random image Displays a random image on a web page. Images are selected from a folder of your choice. <?php /* * Name your images 1.jpg, 2.jpg etc. * * Add this line… Read More

Display a different image for each day of the week

Display a different image for each day of the week Description This PHP script will get the day of the week from the server date and then display an image (jpg or gif)… Read More

PHP: Random Quote

PHP: Random Quote Make a file called quotes.txt Put each quote on it’s on line. Here’s a script: <? $r_array=file(‘quotes.txt’); shuffle($r_array); echo $mQuotePath[0]; echo $r_array[0]; ?>

Making ZIP file using php

Making ZIP file using php createZip.inc.php <?php include_once(“createZip.inc.php”); $createZip = new createZip; $createZip -> addDirectory(“dir/”); $imgdir = ‘/public_html/logs/’; // the directory, where your images are stored $allowed_types = array(‘png’,’jpg’,’jpeg’,’gif’); // list of filetypes… Read More

Making ZIP file using php

createZip.inc.php <?php include_once("createZip.inc.php"); $createZip = new createZip;   $createZip -> addDirectory("dir/"); $imgdir = ‘/public_html/logs/’; // the directory, where your images are stored     $allowed_types = array(‘png’,’jpg’,’jpeg’,’gif’); // list of filetypes you want to show … Read More

Follow

Get every new post delivered to your Inbox.

Join 36 other followers