Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to upload image on web from mysql only in jsp
    text
    copied!<p>Currently I am working on a web site which is totally in html+jsp using eclips. Now my problem is in uploading a file. I am able to display image from my local machine to my html page,but I want to store that image into mysql database and then display on main web page.</p> <p>Suppose I have two pages in first page operator select any image from its local machine then it will also display on image view on same page,and when operator click on upload image then image will display on web-site. </p> <p>As said earlier I am able to display image on operator's page but how to save it in mysql database and then retrieve it on web-site.</p> <p>It could be possible to do this task in .jsp file only?</p> <p>Here is my code to display image from local machine,</p> <pre><code> &lt;div class="file"&gt; &lt;ul class="thumbnails"&gt; &lt;li class="span4"&gt; &lt;a href="#" class="thumbnail"&gt; &lt;div id="imgThumbId"&gt;&lt;/div&gt; &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;form action="advertise.jsp"&gt; &lt;fieldset&gt; &lt;legend&gt;Upload Image&lt;/legend&gt; &lt;label for="file"&gt;Choose photo&lt;/label&gt; &lt;input type="file" name="file" id="file" /&gt;&lt;br/&gt; &lt;input type="submit" name="upload" id="upload" value="Upload photo" onclick="PreviewRecipeImage();"/&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>and here is javascript code</p> <pre><code>&lt;script type="text/javascript"&gt; function PreviewRecipeImage(){ var file = document.getElementById('file').files[0]; // create img tag for selected recipe image file var img = document.createElement("img"); img.id = "imgid"; img.classList.add("obj"); img.file = file; //img.width = 90; //img.height = 90; //ClearThumb1Image(); document.getElementById('imgThumbId').appendChild(img);// append img tag to recipe image tag var reader = new FileReader(); reader.onload = (function(aImg) { return function(e) { aImg.src = e.target.result; }; })(img); reader.readAsDataURL(file); } &lt;/script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload