Archive for the ‘PHP’ Category

How to list all entries in a directory using PHP

It displays both "." and ".." entries also.

<?php
 
if ($handle = opendir('/path/to/files')) {
    echo "Directory handle: $handle\n";
    echo "Entries:\n";
 
    /* This is the correct way to loop over the directory. */
    while (false !== ($entry = readdir($handle))) {
        echo "$entry\n";
    }
 
    /* This is the WRONG way to loop over the directory. */
    while ($entry = readdir($handle)) {
        echo "$entry\n";
    }
 
    closedir($handle);
}
?>
 

Read more »

HTML5 download Attribute

 
The download attribute allows you to set a separate file download name than the actual link endpoint itself.
 
 
Place the download attribute on a link in html file.
 
Example
 
<!– will download as "jijokjose.zip" –>
 
<a href="http://www.jijokjose.com/wp-content/uploads/2013/01/ajax_auto_complete.zip" download="jijokjose.zip">Download Sample File</a>
 
Result
 
 
..and when the user clicks the link, the download attribute appears in the save dialog instead of the garbled mess that was there before.
 

Read more »

Auto Complete Text box using AJAX in PHP

 

To download code – Click Here

 
To view the live demo please enter your country name.
 
 

Read more »