我正在设置一个从ts视频文件中读取信息的应用程序。如果文件为10 Kb,则他的功能可以正常工作,但是当文件长得多(大约20.478 KB)时,文件将被冻结,而我无法获取任何信息。没有filesize(),也没有files()或其他任何东西。我几乎尝试了所有事情,但是我没有主意。
HTML代码:
<!DOCTYPE html>
<html>
<head>
<title>Proyecto</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="post" action="leerBytes.php" enctype="multipart/form-data">
Choose a file: <br>
<input type="file" name="file" id="file"> <br>
<input type="submit" name="button" id="button" value="Send" onclick="post"> <br>
</form>
</body>
</html>
PHP代码:(leerBytes.php)
<?php
if(isset($_POST["button"])){
echo "File sent <br>";
$file = $_FILES['file'];
echo "<br>";
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileError = $_FILES['file']['error'];
$fileType = $_FILES['file']['type'];
$fileExt = explode ('.',$fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('ts');
if (in_array($fileActualExt, $allowed)) {
if($fileError === 0){
$fileNameNew = uniqid('',true).".".$fileActualExt;
$fileDestination = 'uploads/' .$fileNameNew;
move_uploaded_file($fileTmpName, $fileDestination);
$byte = new leerBytes();
$byte ->leerByte($fileDestination);
}else{
echo 'Error.';
}
}else{
echo 'Wrong file.';
}
}
class leerBytes{
function leerByte($file){
$filesize = filesize($file);
echo $filesize;
$fileopen = fopen($file, "rb") or die("Can't get fileopen");
$bytesize = 8;
if($fileopen){
$header = null;
$body = null;
echo "There's data";
$buffer = fgets($fileopen, 4096);
echo $buffer;
fclose($fileopen);
} else {
echo "Error";
}
}
}
?>
我希望获取文件大小或数组中文件的信息。 我在这里留下一些文件作为示例:https://drive.google.com/drive/folders/1Hge4w8cIZBRm3TskABWcQZSoFFVUMx0-?usp=sharing