Since it is necessary to determine if the uploaded file has been modified, the MD5 value of the uploaded file needs to be recorded, and the method of obtaining the MD5 value of the file is recorded here.
Copy the 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 documents to be calculated.
Parameter charlist, optional. Specify hexadecimal or binary output format: TRUE-original 16 character binary format; FALSE-Default. 32 character hexadecimal number.
Copy the 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 the Code code as follows:
<?php
$MD 5file = md5_file ("test.txt");
File_put_contents ("Md5file.txt", $md 5file);
?>
In this example, we will detect if "test.txt" has been changed (that is, if the MD5 hash has been changed):
Copy the 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 the Code code as follows:
The file is OK.
http://www.bkjia.com/PHPjc/825398.html www.bkjia.com true http://www.bkjia.com/PHPjc/825398.html techarticle since it is necessary to determine if the uploaded file has been modified, the MD5 value of the uploaded file needs to be recorded, and the method of obtaining the MD5 value of the file is recorded here. Copy the code code as follows: if (Isset ($_fil ...