I am working on an simple app which allows user to upload images and videos while doing so automatically generates a < div > for each content that was uploaded and wraps it. Each uploaded picture stays next to the previous one specially stylized.
What I want is to after every upload I make (image or video), it stays there even if I close my app. And if I remove it in the future, naturally it would dissapear.
Is it possible to do it without any local database, if not what is the best way to do it with a database and which module to use?
//image upload
function uploadImage(file) {
var reader = new FileReader();
var div_img = $('<div class="content"></div>');
reader.onload = function(event) {
img_url = event.target.result;
div_img.html(('<img src="' + img_url + '" onmousedown="return false" />'));
div_img.appendTo('#wrapper');
}
reader.readAsDataURL(file);
}
$("#the-image-file-field").change(function() {
uploadImage(this.files[0])
});
//video upload
function renderVideo(file) {
var reader = new FileReader();
var div_vid = $('<div class="content_video"></div>');
reader.onload = function(event) {
vid_url = event.target.result;
div_vid.html(('<video controls><source src="' + vid_url + '" type="video/mp4" /> '));
div_vid.appendTo('#vid_container');
}
reader.readAsDataURL(file);
}
$("#the-video-file-field").change(function() {
renderVideo(this.files[0])
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type='file' id="the-image-file-field" accept="image/*" />
<input type="file" id="the-video-file-field" accept="video/*" />
<div id="wrapper" class="wrapper">
<div id="vid_container"></div>
</div>
<script src="javascripts/uploader.js"></script>