Quizzes & Puzzles6 mins ago
How To Add A Same Image Without Change In Html When Creating Website Bulider?
0 Answers
I am trying to make a website builder wherein we have options to add HTML elements like text, images, videos etc. For uploading image through the device, I used
$(document).ready(function() {
$("#addImage").click(function() {
$("#fileinput").click();
});
$("#fileinput").click(function() {
$("#fileinput").change(function() {
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(this.files[0]);
}
});
});
function imageIsLoaded(e) {
var picture = ''
$("body").append(picture);
}
});
Upload image
I linked the function to another button and hid the actual file input button so that it looks good.
This works fine only for the first time. The nth time I add an image, the image is will be added n times.
Also, since i am adding images I need an alternate for change() since I may want to add same image without a change.
$(document).ready(function() {
$("#addImage").click(function() {
$("#fileinput").click();
});
$("#fileinput").click(function() {
$("#fileinput").change(function() {
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(this.files[0]);
}
});
});
function imageIsLoaded(e) {
var picture = ''
$("body").append(picture);
}
});
Upload image
I linked the function to another button and hid the actual file input button so that it looks good.
This works fine only for the first time. The nth time I add an image, the image is will be added n times.
Also, since i am adding images I need an alternate for change() since I may want to add same image without a change.
Answers
Best Answer
Nobody has yet answered this question. Once some answers have been given, Jagadishjack will be able to select one answer as the best. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.There are no answers available for this question.
Related Questions
Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.