Tema: Re: reikia pagalbos java web programinimui
Autorius: JAlexoid
Data: 2009-05-20 02:32:29
Na tai nera naujiena. Jeigu uzsimintum kad failo pavadinima issaugai, 
tai lengviau butu.
Kitakart zinosi kad problema reikia aprasyti iki galo ir is skirtingu 
perspektyvu.

Tadas B. wrote:
> ikeliu sprendima ateities kartoms:) tik kas gali pasakyti, kaip man 
> kelis menesius viskas veike????
> tik nebeversiu i LT, pakopinu is mano posto kitame forume:
> 
> the problem was determining file extension in this line:
> fileUpload1.getUploadedFile().getContentType().substring(7)
> 
> 
> because different browsers differently return file name (Some browsers 
> return complete path name, some don't) and then I pass bad "format" 
> parameter to my getPreview() method. The resolution is from this 
> link:http://www.netbeans.org/kb/60/web/fileupload.html determining file 
> name, then extension
> 
> String uploadedFileName = fileUpload1.getUploadedFile().getOriginalName();
>         int index = uploadedFileName.lastIndexOf('/');
>         String justFileName;
>         if ( index >= 0) {
>             justFileName = uploadedFileName.substring( index + 1 );
>         } else {
>             index = uploadedFileName.lastIndexOf('\\');
>             if (index >= 0) {
>                 justFileName = uploadedFileName.substring( index + 1 );
>             } else {
>                 justFileName = uploadedFileName;
>             }
>         }
> 
> 
> extension:
> 
> justFileName.substring(justFileName.lastIndexOf(".")+1)