脚本宝典收集整理的这篇文章主要介绍了php – 将Chrome中记录的WAV文件保存到服务器,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
http://webaudiodemos.appspot.com/AudioRecorder/index.html
但我需要能够将文件保存到我运行的Linux服务器上.这是实际将blob记录的数据发送到服务器并将其保存为一个能够吸引我的.wav文件.我没有必要的PHP和/或AJAX知识,关于如何将blob保存到URL并且如我已经理解的那样处理Linux上的二进制文件,这使得保存.wav文件确实具有挑战性.我非常欢迎任何指示正确的方向.
function upload(blob) { 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("that_random_filename.wav",blob); xhr.open("POST","<url>",true); xhr.send(fd); }
<?PHP // get the temporary name that PHP gave to the uploaded file $tmp_filename=@R_360_825@["that_random_filename.wav"]["tmp_name"]; // rename the temporary file (because PHP deletes the file as soon as IT's done with it) rename($tmp_filename,"/tmp/uploaded_audio.wav"); ?>
之后你可以播放文件/tmp/uploaded_audio.wav.
但要记住! /tmp/uploaded_audio.wav是由用户www-data创建的,并且(默认情况下为PHP)用户无法读取.要自动添加适当的权限,请附加该行
chmod("/tmp/uploaded_audio.wav",0755);
希望这可以帮助.
以上是脚本宝典为你收集整理的php – 将Chrome中记录的WAV文件保存到服务器全部内容,希望文章能够帮你解决php – 将Chrome中记录的WAV文件保存到服务器所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。