Create Image from Data URL
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 开发者_如何学Pythonin a data URL and output a file in which I could move to that folder.
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).
精彩评论