gpt4 book ai didi

Javascript 获取视频长度

转载 作者:行者123 更新时间:2023-11-29 21:13:20 25 4
gpt4 key购买 nike

您好,我有以下代码:

          <form action="postvideophp.php" method="post" enctype="multipart/form-data">       
<input id="videoage" type="file" name="video" style="-webkit-appearance: none;-webkit-border-radius: 0;margin-left:-242px;margin-top:10px;opacity:0;">
<label for="videoage" id="labelvideo">Choose Video...</label>

<textarea id="postTitleStyle" onkeyup="countChars('postTitleStyle','titlecount');" onkeydown="countChars('postTitleStyle','titlecount');" onmouseout="countChars('postTitleStyle','titlecount');" name="title" rows="1" maxlength = "180" placeholder="Title"><?php echo $title;?></textarea>
<a id="titlecount" style="color:#F52025;Font-family:Arial Black;display:table;margin-top:-20px;margin-left:840px;">0</a>
<textarea id="postTagStyle" onkeyup="countChars2('postTagStyle','descripcount');" onkeydown="countChars2('postTagStyle','descripcount');" onmouseout="countChars2('postTagStyle','descripcount');" name="desc" rows="2" maxlength = "1000" placeholder="Description"><?php echo $DESC;?></textarea>
<a id="descripcount" style="color:#3FDA21;Font-family:Arial Black;display:table;margin-top:-20px;margin-left:840px;">0</a>
<center><input type="submit" class = "Post2" value="[&nbsp;&nbsp;Post&nbsp;&nbsp;]"></center>
</form>

这是我发布后的一些 php 代码:

if(FileSize($_FILES["video"]["tmp_name"]) >= 120){
$uploadable = false;
header("Location:post-video");
$_SESSION["FLAW"] = '10';

}

如果发布的视频的文件大小大于 120 字节(例如),我希望浏览器转到称为视频后的错误屏幕。我目前遇到的问题是,如果用户上传一个非常大的视频文件,它会发布整个视频,这可能需要 10 分钟。视频发布后,如果大于 120 字节,则会显示错误屏幕。有没有办法可以使用 javascript 尽早检测视频的大小?如果是这样,我怎样才能快速做到这一点?

最佳答案

您可以添加一些 JavaScript 来检查这一点:

 var file = document.getElementById("videoage").files[0]; 
if (file.size > 120) { /* do something */ }

关于Javascript 获取视频长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40664527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com