enctype发生文件上传代码错误 [英] file upload code error occures by the enctype
本文介绍了enctype发生文件上传代码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在用Java上传文件时,总是向数据库输入null值,我认为是因为表单标签中的enctype ="multipart/form-data"
when uploading a file in java, always enters null value to the database , i think it because of the enctype="multipart/form-data" in the form tag
推荐答案
在将Mime Type值放入数据库之前,必须先获取它.
例如:
You must get the Mime Type value before putting it into your database
For example:
import java.net.*;
public class GetMimeType {
public static void main(String[] args) {
FileNameMap fileNameMap = URLConnection.getFileNameMap();
String mimeType = fileNameMap.getContentTypeFor("JavaFile.jsp");
System.out.println("mimeType="+ mimeType);
}
}
.JSP文件的Mime类型为:mime类型"text/html"
The Mime Type for .JSP files are: mime type "text/html"
这篇关于enctype发生文件上传代码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文