我正在尝试允许用户使用HTML Media Capture从网站内拍摄视频。但是,当我尝试从iPhone X或朋友的iPhone 8上传视频时,仅发送音频,而不发送视频。它可以在其他手机上正常工作。
以下HTML代码触发了iPhone相机,有人可以通过它录制视频:
<form id="form1" enctype="multipart/form-data" method="post" action="Upload.aspx">
<div>
<label for="fileToUpload">Take or select video</label><br />
<input type="file" name="fileToUpload" id="fileToUpload" onchange="fileSelected();" accept="video/*" capture="false" />
</div>
<div>
<input type="button" onclick="uploadFile()" value="Upload" />
</div>
</form>
用于上传文件以将文件发送到PHP的Javascript代码:
function uploadFile() {
var fd = new FormData();
var count = document.getElementById('fileToUpload').files.length;
for (var index = 0; index < count; index++) {
var file = document.getElementById('fileToUpload').files[index];
fd.append('fileToUpload', file);
}
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.open("POST", "upload.php");
xhr.send(fd);
}