Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法将文件上载到服务器页面_Javascript_Php_Record - Fatal编程技术网

Javascript 无法将文件上载到服务器页面

Javascript 无法将文件上载到服务器页面,javascript,php,record,Javascript,Php,Record,当按下上传链接时,我无法检索服务器页面上的音频文件。我们将非常感谢您的任何帮助。 以下是用于上载的javascript代码: //upload link var upload = document.createElement('a'); upload.href="#"; upload.innerHTML = "Upload"; upload.addEventListener("click", function(event){ var xhr=new XMLHttpRequest();

当按下上传链接时,我无法检索服务器页面上的音频文件。我们将非常感谢您的任何帮助。 以下是用于上载的javascript代码:

//upload link
var upload = document.createElement('a');
upload.href="#";
upload.innerHTML = "Upload";
upload.addEventListener("click", function(event){
      var xhr=new XMLHttpRequest();
      xhr.onload=function(e) {
          if(this.readyState == 4) {
              console.log("Server returned: ",e.target.responseText);
          }
      };
      var fd=new FormData();
      fd.append("audio_data",blob, filename);
      xhr.open("POST","upload.php",true);
      xhr.send(fd);
});
li.appendChild(document.createTextNode (" "));  //add a space in between
li.appendChild(upload);  //add the upload link to li
//add the li element to the ol
recordingsList.appendChild(li);
下面是php代码:

<?php
  print_r($_FILES); //this will print out the received name, temp name, type, size, etc.
  $size = $_FILES['audio_data']['size']; //the size in bytes
  $input = $_FILES['audio_data']['tmp_name']; //temporary name that PHP gave to the uploaded file
  $output = $_FILES['audio_data']['name'].".wav"; //letting the client control the filename is a rather bad idea
  //move the file from temp name to local folder using $output name
  move_uploaded_file($input, $output)
?>

正在发生这种类型的错误:
为输出指定完整的目标路径,而不仅仅是文件名

$output = "C:\temp\".$_FILES['audio_data']['name'].".wav";

有时你也需要向前斜杠而不是向后斜杠。请注意安全问题,浏览器提供的文件名可能包含baaad内容。

尝试使用目标路径时仍然存在问题。还有其他建议吗?