To preserve the uploaded image on page refresh, you can make use of the browser's local storage. Here's an example solution using JavaScript:
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
output.onload = function() {
URL.revokeObjectURL(output.src); // free memory
localStorage.setItem('image', output.src); // store the image URL in local storage
}
};
// Check if there is a stored image URL in local storage
var storedImage = localStorage.getItem('image');
if (storedImage) {
var output = document.getElementById('output');
output.src = storedImage;
}
This solution stores the image URL in the browser's local storage when the image is loaded. On page refresh, it checks if there is a stored image URL in the local storage and sets it as the source of the output element.
Note: Local storage is specific to each browser and device, so the image will only be preserved on the same browser and device where it was uploaded.
Security Error: Content at http://success-stories.test/blog/create may not load data from blob:http://success-stories.test/2bc2ddca-d2d4-40ed-90f8-bf856c35f928.