[PATCH] Passthrough MD5/SHA1 calculation of uploaded files

php.internals

David Santinoli

22 years ago
Hi, I'm submitting a 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 only defined upon request of the corresponding digest. The patch was produced against the current CVS version of rfc1867.c (PHP_4_3 branch, v1.122.2.14). Cheers, David
-- David Santinoli, Milano + <david@santinoli.com> Independent Linux/Unix consultant + http://www.santinoli.com