Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- How to blend adsense inside your post?
- Formatting my post
- PHPWind-- A PHP forum script applcaition in China
- PHP: add a download as pdf file button in report page
- Notepad++ - Add C++ compiler
- PHP connect IBM db2 database in XAMPP
- Datatable export excel wraptext and newline
- phpexcel toggle expand and hide column in EXCEL and summary
- Renew SSL certificate from StartSSL
- ActionScript 3.0 demo: create a falling snow in flash CS6
Thursday, September 13, 2012
PHP, check if a file is modified using md5_file
To check if a file is modified in PHP, we use md5 algorithm and PHP function md5_file() function
1) First, we store the file for example " test.txt" md5 in md5test.txt using PHP function md5_file
<?php
$md5file = md5_file("test.txt");
file_put_contents("md5test.txt",$md5file);
?>
2) As the time goes by, we can compare the md5 of the file to the md5 stored.
<?php
$md5file = file_get_contents("md5test.txt");
if (md5_file("test.txt") == $md5file)
{
echo "The file test.txt does not change.";
}
else
{
echo "The file test.txt has been changed.";
}
?>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment