Question

I have created a HTML5 image uploader using canvas. I have the image data using

Canvas.toDataURL();

which is in the form

data:image/png;base64,<base64image string>

I sent the above data to php which will be used to upload the image to amazon server.

I normally pass the return value of

file_get_contents(path_to_file_to_upload);

to the amazon sdk and the work gets done. Now how do i have the base64 image data converted into file_get_contents type data to upload the file.

I am not allowed to create a file in the server.Is there any way of creating a temp image and get the file_get_contents data from that temp file??

Était-ce utile?

La solution

Pass the return value of base64_decode() instead of file_get_contents to the AWS SDK. file_get_contents loads a file into a string, base64_decode loads a base64 string and returns a string. Since you have a base64 string and not a file, you would call base64_decode.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top