|
Hash (Check) Files
If (! Empty ($ _ FILES )){
If ($ _ FILES ["file"] ["error"]> 0 ){
Switch ($ _ FILES ["file"] ["error"]) {
Case 1:
Echo"Error: The uploaded file exceeds the upload_max_filesize directive in php. ini
";
Break;
Case 2:
Echo"Error: The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
";
Break;
Case 3:
Echo"Error: The uploaded file was only partially uploaded.
";
Break;
Case 4:
Echo"Error: No file was uploaded.
";
Break;
Case 6:
Echo"Error: Missing a temporary folder.
";
Break;
Case 7:
Echo"Error: Failed to write file to disk.
";
Break;
Case 8:
Echo"Error: a php extension stopped the file upload.
";
Break;
Default:
Echo"Unknown error occured.
";
}
} Else {
Echo 'upload: '. $ _ FILES ['file'] ['name'].'
';
Echo 'type: '. $ _ FILES ['file'] ['type'].'
';
Echo 'Size: '. (round ($ _ FILES ['file'] ['size']/1024, 2). 'kb
';
If (array_search ($ _ POST ['algo'], hash_algos () = false ){
Echo 'unknown hashing algorithm requested.
';
} Else {
Echo 'hashing Algorithm: '. $ _ POST ['algo'].'
';
$ Hash = hash_file ($ _ POST ['algo'], $ _ FILES ['file'] ['tmp _ name']);
Echo 'calculated hash: '. $ hash .'
';
If ($ _ POST ['expash ']! = 'None '&&! Empty ($ _ POST ['expyash ']) {
Echo 'expected hash: '. $ _ POST ['expyash'].'
';
Echo ($ hash = $ _ POST ['expyash '])? 'Hash matched expected value.':'Hash did not match expected value.';
Echo'
';
}
}
}
?>
Again
} Else {
?>
}
?>
|