I have an error when uploading an image to my DB the name takes it null

0

Servlet

String nombre = request.getParameter("Nombre");
//String valor = request.getParameter("valor");
String img_producto = "imagenes/" + items.getName();
int id_categoria = 2;
float precio = 2200;
int stock = 10;

String query = "INSERT INTO productos(nombre,img_producto,id_categoria, precio,stock) VALUES ('" +nombre+ "','" + img_producto + "','" + id_categoria + "','" + precio + "','" + stock + "');";
Statement stm = c.createStatement();
stm.executeUpdate(query);
stm.close();
c.close();

jsp

<form id="FormPedido" class="form-horizontal" action="UploadFile" method="POST" enctype="multipart/form-data">
    <div class="form-group">
        <label  class="col-md-3 control-label">Selecciones la imagen:</label>
        <div class="col-md-7">
            <input type="file" name="file" id="file" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-3 control-label">Nombre Del Producto </label>
        <div class="col-md-7">
            <input type="text" placeholder="ejem: Tentacion Oreo" name="Nombre" id="Nombre">
        </div>
    </div>
    <input  type="submit" value="Guardar"/>
</form>

<script>
    $(function () {
        $("#file").change(function () {
            var name = $("#file").val();
            var arreglo = name.split("\");
            console.log(arreglo);
            var image_name = arreglo[2];
            $("#file_name").val(image_name);
        });
    });                                     
</script>
    
asked by juan 14.08.2018 в 23:38
source

0 answers