I'm working with servlet / jsp.
I have an input type file and one img in jsp and would like to get its url to the servlet. I tried it like this, but it did not work, the request is null:
JSP:
<script>
var loadFile = function (event) {
var output = document.getElementById('imgTpProd');
output.src = URL.createObjectURL(event.target.files[0]);
};
</script>
<label id="lblInputFile" for='selecao-arquivo'>Selecionar um arquivo </label>
<input id="selecao-arquivo" name="txturlimage" type="file" accept="image/*" onchange="loadFile(event)">
<div id="imgGrupProd">
<img src="">
</div>
Servlet:
String s = request.getParameter("txturlimage");
Imagine a local application, local images and a local bd ...
I have a product table and this one has a url field of an image, which the user selects by an input file. I need to save the image path in the bd.
It's not possible?And all the records that contain pictures, profile photos, how are they made?
Is there any solution without using javascript and php?
If not, I would like a simple javascript / php code (commented),i am not familiar with the programming languages.