你好,我有以下代码:的Javascript获取视频长度
<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="[ Post ]"></center>
</form>
这里是我的一些PHP代码它被张贴后:
if(FileSize($_FILES["video"]["tmp_name"]) >= 120){
$uploadable = false;
header("Location:post-video");
$_SESSION["FLAW"] = '10';
}
我想要的浏览器访问错误如果发布的视频的文件大小大于120个字节(例如),则称为后视频。我现在遇到的问题是它会发布整个视频,如果用户上传一个非常大的视频文件,可能需要10分钟。视频发布后,它大于120bytes,显示错误屏幕。有没有办法,可能使用JavaScript来尽早检测视频的大小?如果是这样,我该如何快速做到这一点?
你可以添加一些JavaScript来检查这个: 'var file = d 。ocument.getElementById( “videoage”)文件[0]; if(file.size> 120) {/ *做些什么* /}' – vbguyny
@vbguyny感谢它的工作回答,所以你可以得到信用 – user7133318
谢谢。您应该能够将我的评论标记为答案。 – vbguyny