I consider building an application with Wappler using SQLite 3 as the database.
However, one feature I strongly want is for users to paste images from their clipboards into a field/container in the application. These images have never been saved to disk. Think of it as a BLOB, where the end user submits the content on the clipboard to the application without saving it to an image file on disk.
Thanks, I was starting to suspect that JavaScript may be needed, particularly after checking out this one. The images are typically small and could be encoded as BASE64 and stored in the database. I probably need to try this out with just JavaScript first, but it could be the solution that will work for me.
O'mighty Deepseek! I seek your wisdom. I'd like some solution to allow a User to paste the contents of their clipboard, an image for this purpose, to a web form, and have the value encoded to base 64 for saving to a database by echoing the value to a hidden form input within the form. So would need an area where the user could paste the contents in to and a corresponding hidden field in base 64. Can you think of a stylish and intuitive way of accomplishing this in a cross browser way?
Clipboard Image to Base64 Solution
Here's a stylish, cross-browser solution that allows users to paste images from their clipboard into a web form and converts them to Base64 for database storage:
Works with both modern clipboard API and older window.clipboardData
Graceful fallbacks
User Experience:
Immediate image preview
Clear button to remove the image
Visual feedback during interactions
Technical Implementation:
Converts image to Base64 automatically
Stores result in hidden input for form submission
Handles both direct paste and file drops
Server-side Consideration
Remember that Base64 images can be quite large. You may want to:
Validate the image size on the client before submission
Consider compressing the image before storing
Set appropriate size limits in your server-side validation
Haven't got time to test it right now but DeepSeek seems to get things right first time unlike other Models which enjoy wasting thousands of tokens (am very sure this is by design)... Cough cough, Claude, cough cough...
Yes, but that would kill the concept. It would be too much overhead.
The images would be small notices from typically old online newspapers, normally taking up only a few percent of a newspaper page.
I do plan to offer the option of adding image files, though, but if I can't make it work with just a paste from the clipboard, then it would be too cumbersome to work effectively.
Interesting, I've found some similar examples online. Need to check into this and try it out. It seems that the work needs to be done mainly with JavaScript, though, so not so much a Wappler issue.
Definitely something that is outside the scope of Wappler natively and would require a custom implementation such as the one outlined above. Good luck with whatever way to select to implement it. Be sure to update the Topic when you have a solution as am sure others would be interested.
It is not feasible to paste a link to an image, as the main source is a site that publishes content with links to whole pages, and only a tiny fraction of a page is of interest. To make things "worse", these pages are actually tiles of small images presented together as one big image (to facilitate zooming in and out, as they have several sizes of these tiles on the server side).
So the easy way to handle this is to take a snapshot of the relevant part of the page.
Where text2 is a hidden input with: {{pasted_image}} value like: dmx-bind:value="pasted_image" type="hidden"
(pasted_image will be set on our javascript code)