admin管理员组文章数量:1333210
I am working on the audio record. Now I want to save that recorded audio in our local directly. When I record audio it is returning blob URL like:
blob: .
When I hit this URL it plays recorded audio. Now I am sending that blob URL from js to PHP script to save your local directory but it is not working.
How can I do that?
I am working on the audio record. Now I want to save that recorded audio in our local directly. When I record audio it is returning blob URL like:
blob: http://example./7737-4454545-545445.
When I hit this URL it plays recorded audio. Now I am sending that blob URL from js to PHP script to save your local directory but it is not working.
How can I do that?
Share Improve this question edited May 5, 2017 at 5:43 Vikrant 5,04618 gold badges51 silver badges75 bronze badges asked May 2, 2017 at 4:24 RAC BRAC B 411 silver badge8 bronze badges 1- It's not helpful if you don't post your code and tell us exactly what is not working(JavaScript not sending?php not receiving?file not saving? Saved but not readable?) – Nick Li Commented May 2, 2017 at 4:28
1 Answer
Reset to default 6Blob URL
lifetime is linked to document
which created Blob URL
from Blob
or File
object. Blob URL
cannot be posted to server as reference for a Blob
stored at snapshot state. See Blob URL Store.
You can use fetch()
, Response.blob()
to get Blob
representation of Blob URL
, post FormData
to server.
// `blobURL` : `"blob:http://example./7737-4454545-545445"`
fetch(blobUrl).then(response => response.blob())
.then(blob => {
const fd = new FormData();
fd.append("fileName", blob, "file.ext"); // where `.ext` matches file `MIME` type
return fetch("/path/to/server", {method:"POST", body:fd})
})
.then(response => response.ok)
.then(res => console.log(res))
.catch(err => console.log(err));
本文标签: javascriptHow to save blob url data in a directoryStack Overflow
版权声明:本文标题:javascript - How to save blob url data in a directory - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742222397a2435526.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论