Create Image from Data URL

回眸只為那壹抹淺笑 提交于 2019-12-05 07:15:54

问题


What I was hoping to do was use the JavaScript "readAsDataURL" method of the "FileReader" object in order to read file input from a drag and drop. Then I wanted to use Ajax with a PHP upload file in order to create a file and upload it to an "uploads" folder on the server.

I was wondering if there was a function in GD or something that would allow me to read in a data URL and output a file in which I could move to that folder.


回答1:


A data image URL will usually be base64 encoded, and will then contain a JPG, GIF, or PNG image which you can store.

So a simple base64_decode() should do to turn the data into readable form; if you can't know what format the file was in, you may have to write it onto disk to do a getimagesize() on it (unless you can use one of the new "memory" fopen wrappers shown here).



来源:https://stackoverflow.com/questions/4672392/create-image-from-data-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!