Bart,

looks like a character encoding problem. The mangled character in the
filename (ᅵ) is meant to be a german u-umlaut.
I can't offer any more advice to resolve the problem as I am working on this
type of problem myself :-(

Martin

> -----Ursprüngliche Nachricht-----
> Von: Bart Frackiewicz [mailto:[EMAIL PROTECTED] 
> Gesendet: Mittwoch, 7. September 2005 14:22
> An: Struts Users Mailing List
> Betreff: Upload: strange characters in german filename
> 
> 
> Hello,
> 
> after uploading a file, getFileName() returns me always a wrong 
> filename, if the filename contains one of the german umlaute 
> (like ü, ä 
> or ö). The filename looks like: "Angebot_Tipps fᅵr Kids.doc" (i 
> display it BEFORE i save the name in the database). This 
> error appears 
> _only_ in the input-file tag, if i enter some characters in a normal 
> input-field, everything goes fine.
> 
> Is this a known error? I found nothing in the web. Is here anyone 
> running Struts / upload running succesful with german filenames?
> 
> TIA, Bart
> 
> Versions: Tomcat 5, Struts 1.2.4, java version "1.5.0_04" on Linux
> 
> Code:
> 
> package de.om.crm.struts;
> 
> ..a lot of imports ...
> 
> import org.apache.struts.upload.FormFile;
> 
> /**
> * @author bart
> *
> * TODO To change the template for this generated type comment go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> public class MarketingMailingAction extends Action {
> 
>    /* (non-Javadoc)
>    * @see
>    */
>    private String tmpUploadFile = null;
> 
>    public ActionForward execute(ActionMapping mapping, 
> ActionForm form,
>        HttpServletRequest request, HttpServletResponse 
> response) throws 
> Exception {
> 
>      // load form
>      MarketingMailingForm mmf = (MarketingMailingForm) form;
>      HttpSession session = request.getSession(true);
> 
>      ArrayList uploadFiles = (ArrayList) 
> session.getAttribute("uploadFiles");
>      if (uploadFiles == null)
>        uploadFiles = new ArrayList();
>      FormFile file = mmf.getMarketingFile();
> 
>      if (mmf.getAction().equals(mmf.ACTION_SENDEN)) {
>        // .. sends mail
> 
>      } else if (mmf.getAction().equals(mmf.ACTION_UPLOAD)) {
> 
>        // first we clean up the temp directory
>        cleanUpTempDir();
> 
>        if (file != null && file.getFileSize() > 0) {
>          try {
>            // save content
>            // save everything in session
>            HashMap h = new HashMap();
>            h.put("contentType", file.getContentType());
>            h.put("fileSize", new Integer(file.getFileSize()));
>            h.put("fileName", file.getFileName());
>            h.put("tempFileName", 
> getTmpFileFromUpload(file.getInputStream()));
> 
>            uploadFiles.add(h);
> 
>            // also add the file to the form list
>            mmf.getFilesInSession().put(new 
> Integer(uploadFiles.indexOf(h)).toString() , h.get("fileName"));
> 
>          } catch (Exception e) {
>            e.printStackTrace();
>          }
> 
>          // ok, everything goes fine, put again the files into session
> 
>        }
> 
>      }
> 
> 
> 
>      return mapping.findForward("marketingMailing");
>    }
> 
>    private void cleanUpTempDir() {
>      // System.out.println("cleanup " + 
> System.getProperty("java.io.tmpdir"));
> 
>    }
> 
>    private String getTmpFileFromUpload(InputStream is) {
>      if (this.tmpUploadFile == null) {
>        // output
>        try {
>          java.io.File tmp = 
> java.io.File.createTempFile("mma_", ".tmp");
>          BufferedOutputStream os = new BufferedOutputStream(new 
> FileOutputStream(tmp.getAbsoluteFile()));
> 
>          // input
>          InputStream in = is;
>          int b;
>          while ((b = in.read()) != -1) {
>            os.write(b);
>          }
>          in.close();
>          os.close();
> 
>          return tmp.getAbsolutePath();
>        } catch (Exception e) {
>          e.printStackTrace();
>          return null;
>        }
>      } else {
>        return this.tmpUploadFile;
>      }
>    }
> }
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to