class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
Your code above cannot work anyway: you are trying to instantiate a class with a file that doesn't exist. Indeed, the filename you have is the contents of the file with an image extension, it cannot possibly work.
You should instantiate the class with raw base64 data:
Great, thanks for your help. I have changed the code as per your suggestion and the file was stored, however it is a data.txt file with base64 encoded image. How do I convert it back to jpeg image and store it?Reply
I think this is because of the string appear before the images string, something like " data:image/jpeg;base64, ", remove it and your image will not in .txt formatReply
Great, thanks for your help. I have changed the code as per your suggestion and the file was stored, however it is a data.txt file with base64 encoded image. How do I convert it back to jpeg image and store it?Reply
You should instantiate the class with raw base64 data: