3 Replies Latest reply on Apr 29, 2008 10:24 AM by j-pro

    fileUpload: file name differrs in FF and IE

    j-pro

      Good afternoon dear RF developers!

      Just noticed that in Firefox 2.0.0.14 UploadEvent.getUploadItem().getFileName() is just a file name(i.e. name+extention, like "picture.jpg"), but if I open the same page in IE 7, then UploadEvent.getUploadItem().getFileName() gives me the full path to file + it's name and extention("c:\picture.jpg" for example).

      I think it's not right, how do you think?

      Thanks for your answer.

        • 1. Re: fileUpload: file name differrs in FF and IE

          Hello,

          Yes. This is a known issue. But It won't fixed.

          By security reason FF does not send full fileName to server. But IE does.
          Anyway we can extract full name on client side in FF, but we can not do it in Opera (It impossible by browser's security). So we can not provide cross-browser implementation in this one.

          By the other way we can cut off file name in all browsers, but in this case we restrict functionality that can be usefull, but works only in IE.

          So, keep this note in your mind and be ready that filename returned from UploadItem can be different.

          • 2. Re: fileUpload: file name differrs in FF and IE
            egil

            Hi, just a pointer on this one. As stated earlier you cannot get Firefox to display the full path of the file. The solution is then to make sure that all browsers yield the same result at least (only the filename with extension).

            To do this use:


            String filename = new File(uploadedFile.getFileName()).getName();


            And use filename as the filename instead of uploadedFile.getFileName()

            Works like a charm for me. The only thing you really need is the filename anyway ...

            • 3. Re: fileUpload: file name differrs in FF and IE
              j-pro

              Thanks, Andrei, just wanted to know if you plan to change anything. This issue is not a problem for sure, it's ok ;) Thanks.

              egil, thanks for suggestion ;)