iPhone X和iPhone 8上的HTML Media Capture Video无法正常工作

时间:2018-08-10 22:01:19

标签: javascript html file-upload html5-video mobile-website

我正在尝试允许用户使用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);
}

0 个答案:

没有答案