Windows PHP替换SHA1_文件>;=2GB错误修复

Windows PHP替换SHA1_文件>;=2GB错误修复,php,windows,sha1,Php,Windows,Sha1,因此,对于那些不了解PHP的人来说,64位和32位windows版本都有设计限制,这意味着“文件大小”、“md5_文件”、“sha1_文件”等函数无法读取超过2GB大小的文件,PHP脚本将出错或返回无效/不正确的文件大小 $fname = $_FILES['Filedata']['tmp_name']; $filesource = sha1_file($fname); 具有windows命令提示符的解决方案如下所示 CertUtil -hashfile "C:\Users\C0n\Deskto

因此,对于那些不了解PHP的人来说,64位和32位windows版本都有设计限制,这意味着“文件大小”、“md5_文件”、“sha1_文件”等函数无法读取超过2GB大小的文件,PHP脚本将出错或返回无效/不正确的文件大小

$fname = $_FILES['Filedata']['tmp_name'];
$filesource = sha1_file($fname);
具有windows命令提示符的解决方案如下所示

CertUtil -hashfile "C:\Users\C0n\Desktop\2GB-file.MP4" SHA1
//Check OS is Windows
if(substr(PHP_OS, 0, 3) == "WIN") {
//input file    
$input = 'CertUtil -hashfile "C:\Users\C0n\Desktop\2GB-file.MP4" SHA1';
//Eexecute input and put the response into a array
exec($input, $response);
//Remove spaces between the hash output.
$str = str_replace(' ', '', $response[1]);
//Display the hash of the file
echo $str;
}

如何在PHP代码中使用它来接收大文件的sha1和。

我的工作代码如下

CertUtil -hashfile "C:\Users\C0n\Desktop\2GB-file.MP4" SHA1
<?php

$result = shell_exec ('CertUtil -hashfile "C:\Users\C0n\Desktop\2GB-file.MP4" SHA1');

var_dump ($result);
//Check OS is Windows
if(substr(PHP_OS, 0, 3) == "WIN") {
//input file    
$input = 'CertUtil -hashfile "C:\Users\C0n\Desktop\2GB-file.MP4" SHA1';
//Eexecute input and put the response into a array
exec($input, $response);
//Remove spaces between the hash output.
$str = str_replace(' ', '', $response[1]);
//Display the hash of the file
echo $str;
}