0

When I use enctype=“multipart/form-data” for upload and input many data get null, if delete enctype=“multipart/form-data” it can get data but upload null. My code html

<form action="createvendor" method="post" enctype="multipart/form-data">
    <div>
        <label> <input placeholder="Username:" type="text"
                       name="username" tabindex="1" >
        </label>
    </div>
    <div>
        <label> <input placeholder="Password" type="password"
                       name="password" tabindex="2" >
        </label>
    </div>
    <div>
        <label> <input placeholder="Firstname:" type="text"
                       name="firstname" tabindex="3" >
        </label>
    </div>
    <div>
        <label> <input placeholder="Lastname:" type="text"
                       name="lastname" tabindex="4" >
        </label>
    </div>
    <div>
        <label> <input placeholder="ID card:" type="text"
                       name="personalID" tabindex="5" maxlength="13"
                       onKeyUp="if(isNaN(this.value)){ alert('กรุณากรอกตัวเลข 13 หลักเท่านั้น'); this.value='';}"
                >
        </label>
    </div>
    <div class="registration_form">
        <div style="position: relative;">
            <a class='btn btn-primary'> Choose your ID card picture <input
                    required class="form-control" type="file"
                    style='position: absolute; z-index: 2; top: 0; left: 0; filter: alpha(opacity = 0); -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; opacity: 0; background-color: transparent; color: transparent;'
                    name="picturePersonalID"
                    onchange='$("#upload-file-info").html($(this).val());'>
            </a>&nbsp; <span class='label label-info' id="upload-file-info"></span>
        </div>
    </div>
</form>

I want to upload and input many data and send data to servlet.

Dipen Shah
  • 1,911
  • 10
  • 29
  • 45

2 Answers2

0

If you need in order to upload a file by which you intend to add later on, then you should put @MultipartConfig annotation on your servlet, so that request.getParameter() will work and that all uploaded files can be retrieved by request.getPart().@MultipartConfig(maxFileSize = 1073741824)

kush
  • 79
  • 2
  • 11
-1

@MultipartConfig(maxFileSize = 1073741824) put this annotation on method

MAx
  • 1
  • 1