Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
114
rated 0 times [  118] [ 4]  / answers: 1 / hits: 84401  / 10 Years ago, fri, october 31, 2014, 12:00:00

I have a jpeg as a base64 encoded string.



var image = /9j/4AAQSkZJRgABAQEAS...


I would like to upload this jpeg to the server using FormData.



var data = new FormData();


What is the proper way to append the image to data?


More From » form-data

 Answers
31

Your image data is nothing more than a string, so append it to your FormData object like this:



data.append(image_data, image);


Then on your server side you can store that directly in a database or convert it to an image and store it on the file system. You might find this post helpful.


[#68954] Wednesday, October 29, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tomas

Total Points: 165
Total Questions: 111
Total Answers: 103

Location: Maldives
Member since Tue, Dec 21, 2021
3 Years ago
tomas questions
Thu, Jan 27, 22, 00:00, 2 Years ago
Mon, May 10, 21, 00:00, 3 Years ago
Tue, Jan 5, 21, 00:00, 3 Years ago
;