I received an image in the form of a Bitmap from the clipboard and need to send it to the server as a file. How do I implement this without saving it as a file on the user’s computer?
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
Since you haven’t mentioned the tech stack, I’ll answer this from a general theoretical perspective.
You should turn the clipboard data into a byte stream and send it over an HTTP multipart/form-data request to the server.
You can convert the Bitmap image to a Blob object and send it to the server. I’m assuming you are using pure Javascript, so I’ve done using Fetch. You can use Axios also for the same, for eg: