0
我正在使用JSP表單上傳和Servlet將大型文件存儲在MySQL數據庫中。而且因爲我對Java一般都很陌生,所以我需要一個非常緊急的幫助。 我試圖將文件存儲在一個字符串值,但我得到的錯誤是字符串索引超出邊界。如何在數據庫中保存大文件。
我有數據庫表文件(varchar File_Name,Blob File_data,Varchar File_Date)。 ,我需要存儲
我在Servlet這裏面的代碼上傳的文件: ** BTW:我不知道爲什麼「DiskFileUpload,的parseRequest」有刪除線?
try {
InputStream uploadedFile = null;
<strike>DiskFileUpload</strike> fu = new </strike>DiskFileUpload</strike>();
// If file size exceeds, a FileUploadException will be thrown
fu.setSizeMax(10000000);
List fileItems = fu.<strike>parseRequest</strike>(request);
Iterator itr = fileItems.iterator();
while (itr.hasNext()) {
FileItem fi = (FileItem) itr.next();
//Check if not form field so as to only handle the file inputs
//else condition handles the submit button input
if (!fi.isFormField()) { // If the form fiel is a file
uploadedFile = fi.getInputStream();
}
我應該轉換什麼類型的數據uploadFile cvariable能夠將它存儲在Blob屬性中?
我該如何解決這個問題? – Lujain