在客户端temp文件夹中保存html5 Canvas图片以便上传
问题描述:
我已经通过向视频浏览按钮添加eventListener,从mp4视频创建缩略图并将其显示在同一页面上。 我希望当用户点击保存按钮时,视频以及所有其他字段应保存在已正常工作的数据库中。在客户端temp文件夹中保存html5 Canvas图片以便上传
现在的问题是,我正在尝试发送画布图像作为正常输入类型=文件。
为此,我在我的脑海两个选项:
1- to save the canvas displayed image on client machine drive (html5 localstorage)
2- Or i have to send the canvas image to the server and then have to upload that from the temp uploaded folder (i know this is a stupid idea :)).
我不知道该怎么办?请帮忙
谢谢
答
你不必假定canvas是一个文件。当您在canvas.it上使用canvas.toDataURL('image/png')
时,会返回一个表示编码URL的base64编码字符串,然后您可以通过POST方法将该字符串发送到服务器。
在服务器端重建来自客户端发送的base64编码字符串的图像。
阅读该问题:[将'canvas'图像数据上传到服务器](http://stackoverflow.com/questions/1590965/uploading-canvas-image-data-to-the-server) –