[PATCH] Passthrough MD5/SHA1 calculation of uploaded files

php.internals

David Santinoli

23 years ago
Hi, I'm submitting a patch (previously sent to php-dev as suggested in the [obsolete?] README.SUBMITTING_PATCH) to perform "on the fly" MD5/SHA1 digest calculation of a file uploaded via the HTTP POST method. Since it is not uncommon for applications to require some digest of a freshly uploaded file, doing the math directly in the buffer where the file is being read can save some time. Digest calculation is triggered by setting the special input fields COMPUTE_MD5 and/or COMPUTE_SHA1 to a non-zero value: <input type="hidden" name="COMPUTE_SHA1" value="1"> (note that these assignments must precede the <input type="file" name=...> field, as in the MAX_FILE_SIZE case.) The result is found in the special variables $_FILES[userfile]["md5"] and $_FILES[userfile]["sha1"]. These variables are defined only upon request of the corresponding digest. The patch was produced against rfc1867.c v1.137, but applies to the current CVS file (v1.141) as well. Cheers, David
-- David Santinoli, Milano + <david@santinoli.com> Independent Linux/Unix consultant + http://www.santinoli.com