我想知道如何爲Base64數據轉換,如如何將base64數據轉換爲JavaScript中的PNG文件?
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAAAXNSR0IArs4c6QAAAZhJREFUOBGVk79Lw1AQx+9eU5zcC40u4iLYtBQcpaN0dXBxLeIP6CBugiAIIiooooi4ufgPdC6OYm3TwUVcNIVKR+kgTXPehUZt01TfQZJ33+/nvk2TF4ReUS5n2HcvRUTKA0GagD4AsaoArlJdpyRYPWbmPYACEGUQcBwQakRYsuanTrBcdoVBOT2NmdOdDt0SQEb6UCHe+BrRcshjgUOq8TguzXw6z0jZbNyuNu9ZTw+DNbSalUnMxRbfY1t8Z0N/WSNM0ESr2W4rD2FBczASlywlLyCS0DU4i18itHTnRvAtxdvkcQSgZXFWRXEd8pS/h7Smw7DLWUdqtvP2AAr2w76mwhmSJc8QrO3CDiJea0Z84zIrGSL4X4osiL8h25i8APJWpP93obq03NdVDuXt/CtQGgmtG+YZEaxJ/1chwnnKdTaCMOH9vxwMimF1G+uo8DTQoq7C+GzvzgKuLzAQLdcpKgXHQT94FU+YQV36oYFipNzGJig8kHVfseZ7faJGYxsTezWVJDlkrTEajdaN5K4c0cSP8wV8eoEZjT4J3gAAAABJRU5ErkJggg==
一個PNG圖像(testing.png
)。 並保存這樣
var imageS = new Image();
imageS.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAAAXNSR0IArs4c6QAAAZhJREFUOBGVk79Lw1AQx+9eU5zcC40u4iLYtBQcpaN0dXBxLeIP6CBugiAIIiooooi4ufgPdC6OYm3TwUVcNIVKR+kgTXPehUZt01TfQZJ33+/nvk2TF4ReUS5n2HcvRUTKA0GagD4AsaoArlJdpyRYPWbmPYACEGUQcBwQakRYsuanTrBcdoVBOT2NmdOdDt0SQEb6UCHe+BrRcshjgUOq8TguzXw6z0jZbNyuNu9ZTw+DNbSalUnMxRbfY1t8Z0N/WSNM0ESr2W4rD2FBczASlywlLyCS0DU4i18itHTnRvAtxdvkcQSgZXFWRXEd8pS/h7Smw7DLWUdqtvP2AAr2w76mwhmSJc8QrO3CDiJea0Z84zIrGSL4X4osiL8h25i8APJWpP93obq03NdVDuXt/CtQGgmtG+YZEaxJ/1chwnnKdTaCMOH9vxwMimF1G+uo8DTQoq7C+GzvzgKuLzAQLdcpKgXHQT94FU+YQV36oYFipNzGJig8kHVfseZ7faJGYxsTezWVJDlkrTEajdaN5K4c0cSP8wV8eoEZjT4J3gAAAABJRU5ErkJggg==";
var newFile = new Parse.File("testing.png", imageS);
newFile.save({
success: function() {
console.log("Image Upload Succces");
},
error: function (file, error) {
console.log("Image Upload Error" + error.message);
}
})
但它表明無法創建與數據的Parse.File。
https://stackoverflow.com/questions/21227078/convert-base64-to-image-in-javascript-jquery – Goombah
你的意思是將URL轉換爲文件?例如,顯示圖像,使用數據URL,右鍵單擊並將其保存到文件_not_做你想做的事情?你還試過了什麼? – traktor53
ya將數據網址轉換爲png文件,因爲我想將其保存到數據庫 –