Due to the need to determine whether the uploaded file has been modified, you need to record the MD5 value of the uploaded file, here to record the way to get the file MD5 value.
Copy Code code as follows:
if (Isset ($_files[' Multimedia ')) && $_files[' multimedia '] [' ERROR ']==0]
{
$file _name = $_files[' multimedia ' [' Name '];
$size = getimagesize ($_files[' multimedia '] [' tmp_name ']);
$type = $_files[' multimedia '] [' type '];
$original = $_files[' multimedia '] [' tmp_name '];
$MD 5 = md5_file ($original);
echo $MD 5;
}
Md5_file ()
The Md5_file () function computes the MD5 hash of the file. The MD5 () function uses RSA data security, including the MD5 message selected passage algorithm. If successful, returns the computed MD5 hash, or False if it fails.
Syntax: MD5 (STRING,RAW)
Parameter string, required. Specify the files to be computed.
Parameter charlist, optional. Specify hexadecimal or binary output format: TRUE-original 16 character binary format; FALSE-Default. 32-character hexadecimal number.
Copy Code code as follows:
<?php
$filename = "Test.txt";
$MD 5file = Md5_file ($filename);
echo $MD 5file;
?>
To store the MD5 hash of the "test.txt" file:
Copy Code code as follows:
<?php
$MD 5file = md5_file ("test.txt");
File_put_contents ("Md5file.txt", $md 5file);
?>
In this case, we will detect if "test.txt" has been changed (that is, whether the hash has been changed): MD5
Copy Code code as follows:
<?php
$MD 5file = file_get_contents ("Md5file.txt");
if (Md5_file ("test.txt") = = $md 5file)
{
echo "The file is OK."
}
Else
{
echo "The file has been changed."
}
?>
Output:
Copy Code code as follows:
PS: Here again for you to provide 2 MD5 encryption tools, interested friends can refer to:
MD5 Online Encryption Tool:
Http://tools.jb51.net/password/CreateMD5Password
Online md5/hash/sha-1/sha-2/sha-256/sha-512/sha-3/ripemd-160 Encryption Tool:
Http://tools.jb51.net/password/hash_md5_sha