2016-02-27 78 views
0

我已經通過向視頻瀏覽按鈕添加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 :)). 

我不知道該怎麼辦?請幫忙

謝謝

+0

閱讀該問題:[將'canvas'圖像數據上傳到服務器](http://stackoverflow.com/questions/1590965/uploading-canvas-image-data-to-the-server) –

回答

0

你不必假定canvas是一個文件。當您在canvas.it上使用canvas.toDataURL('image/png')時,會返回一個表示編碼URL的base64編碼字符串,然後您可以通過POST方法將該字符串發送到服務器。

在服務器端重建來自客戶端發送的base64編碼字符串的圖像。