2

Server side, I have a base64 encoded string which represents a jpg image.

My class method expects to have that file inside $_FILES array and I can't change that code.

How can I manually push that base64 inside $_FILES? Should I use a temp file?

Once added to $_FILES, will I be able to access file information like size or tmp_name?

Keep Coding
  • 636
  • 9
  • 26
Jumpa
  • 4,319
  • 11
  • 52
  • 100
  • You would need to save it to disk and manually calculatre all the fields such as size etc. Probably better to just add a method to your class that excepts a base64 string – Steve Mar 24 '15 at 11:09
  • If your class uses `move_uploaded_file` then populating `$_FILES` wont work. `This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.` – Musa Mar 24 '15 at 16:12
  • My class uses that method and your comment was concurrent to my discovery...giving up. *sob* – Jumpa Mar 24 '15 at 16:17
  • I would need to achieve the same, in probably similar environment. Check my question, perhaps we can get an anwser there http://stackoverflow.com/questions/33733870/remove-an-image-that-was-not-put-in-uploads-folder-via-wp-handle-upload. I also put a bounty on it .. – trainoasis Dec 11 '15 at 13:13

0 Answers0