diff --git a/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml b/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml index 6e454d1..b9bc1ba 100644 --- a/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml +++ b/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml @@ -42,7 +42,7 @@ - + diff --git a/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java b/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java index 4ec6e3a..2d774b7 100644 --- a/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java +++ b/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java @@ -1,5 +1,11 @@ package org.yacos.web.author.controller; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.List; import javax.servlet.ServletException; @@ -23,7 +29,7 @@ public class SArticleController extends SimpleFormController { private IArticleManager articleManager; public ModelAndView onSubmit(Object command) - throws ServletException { + throws ServletException, IllegalStateException, IOException { String title = ((FormSubmission) command).getTitle(); String theme = ((FormSubmission) command).getTheme(); @@ -35,12 +41,20 @@ public class SArticleController extends SimpleFormController { System.out.println(liste); - // let's see if there's content there MultipartFile file = ((FormSubmission) command).getFile(); if (file == null) { // hmm, that's strange, the user did not upload anything } + + byte b[] = file.getBytes(); + File file2 = new File(file.getOriginalFilename()); + + FileOutputStream fos = new FileOutputStream(file2); + + fos.write(b); + fos.close(); + Article a = new Article(0, title, theme, "", mainauthor, null, 1); articleManager.addArticle(a);