phphashmd5md5-file

PHP md5_file hash is not the same as other online hash generators


I am uploading a file using PHP which uses md5_hash to create a MD5 hash of the file.

When I upload that same file to other online MD5 hash generators they return something else.

Is there something I am doing wrong?

$MD5 = md5_file($_FILES['inputname']['tmp_name']);
var_dump($MD5);

string(32) "d41d8cd98f00b204e9800998ecf8427e"

https://md5file.com/calculator says:

MD5 3be70563560066c0751a8e9427949bbf

Solution

  • d41d8cd98f00b204e9800998ecf8427e is the MD5-hash of the empty string. This means that the file that the filename $_FILES['inputname']['tmp_name'] points to is empty.

    So, there is a major problem with the upload somewhere... maybe a server configuration error. It's impossible to say though, without further investigations.