PHP obtains the md5 code of the uploaded file. To determine whether the uploaded file has been modified, you need to record the md5 value of the uploaded file. here, record the method for obtaining the md5 value of the file. If (isset ($ _ FILES [multimedia]) $ _ FILES [to determine whether the uploaded file has been modified, you need to record the md5 value of the uploaded file, here we record how to obtain the md5 value of a file.
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'];$md5 = md5_file($original);echo $md5;}
Md5_file ()
MD5 hash of the md5_file () function compute file. The md5 () function uses RSA Data Security, including the MD5 packet excerpt algorithm. If the calculation succeeds, the calculated MD5 hash is returned. if the calculation fails, false is returned.
Syntax: md5 (string, raw)
- The string parameter, required. Specifies the file to be calculated.
- The charlist parameter. optional. The hexadecimal or binary output format is required: TRUE-original 16-character binary format; FALSE-default. 32 characters in hexadecimal notation.
MD5 hash for storing the "test.txt" file:
In this example, we will check whether "test.txt" has been changed (that is, whether the MD5 hash has been changed ):
Output:
The file is ok.
Bytes. If (isset ($ _ FILES ['multimedia ']) $ _ FILES ['...