を使用しています
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
String description = request.getParameter("description"); // Retrieves <input type="text" name="description">
Part filePart = request.getPart("file"); // Retrieves <input type="file" name="file">
String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // MSIE fix.
InputStream fileContent = filePart.getInputStream();
File file = new File("D:\\image123.jpg");
file.createNewFile();
OutputStream stream = new DataOutputStream(new FileOutputStream(file));
IOUtils.copy(fileContent,stream);
}
宣言にenctype = "multipart/form-データを形成:
<form method="POST" action="../propicuploader">
<div class="browsephoto_div">
<label class="takeapicture_btn">
<input type="file" accept=".png, .gif, .jpeg, .jpg" id="imagetoupload" enctype="multipart/form-data" onchange="document.getElementById('myImg').src = window.URL.createObjectURL(this.files[0])" required/>
<span>Browse</span>
</label>
</div>
<div class="ProfilePicsubmit_div">
<input type="submit" class="Profilpicsubmit_btn" value="Next"/>
</div>
</form>
私のサーバーサイドスクリプト:私のクライアント側のスクリプトで再「 例: <form method="POST" action="../propicuploader" enctype="multipart/form-data" >
場合あなたは詳細を知りたい:What does enctype='multipart/form-data' mean?