On 7/18/07, redomancer redomancer <[EMAIL PROTECTED]> wrote:

Hello!
I am not sure i am posting the questions in right place, but i have no
other
option.


Um, yes, you do - the Commons User list is the place for questions like
this. Nevertheless, the answer to your question is in the FileUpload FAQ:

http://jakarta.apache.org/commons/fileupload/faq.html#whole-path-from-IE

--
Martin Cooper


I have problem witch is related to Apache Common File Upload.

First of all - the code I am using for file saving:

/********************************/
                FileItemIterator anIterator = (new
ServletFileUpload()).getItemIterator(aRequest);
                FileItemStream anItem = null;
                InputStream aInputStream = null;
                while (anIterator.hasNext()) {
                    anItem = anIterator.next();
                    aInputStream = anItem.openStream();
                    if (anItem.isFormField())
                        // ... form field
                    else {
                        BufferedInputStream aBufferedInputStream = new
BufferedInputStream(aInputStream);
                        OutputStream aOutputStream = new
FileOutputStream(getRealPath() + anItem.getName());
                        BufferedOutputStream aBufferedOutputStream = new
BufferedOutputStream(aOutputStream);
                        int aStreamedDataSize = 0;
                        while((aStreamedDataSize =
aBufferedInputStream.read())!=-1)
{
                            aBufferedOutputStream.write
(aStreamedDataSize);
                        }
                        aBufferedOutputStream.flush();
                        aBufferedOutputStream.close();
                        aBufferedInputStream.close();
                        aOutputStream.flush();
                        aOutputStream.close();
                    }
                }
/********************************/

getRealPath() is my function what returns the directory where file must be
saved.

And now the problem: anItem.getName() for IE7 returns FULL path to file on
client side machine.
For example: if i had file C:\upload_me.txt, then anItem.getName() will
contain "C:\upload_me.txt" if IE7 submits data;
for other browsers anItem.getName() will contail value "upload_me.txt".

Is it supposed to be so?
What data anItem.getName() must return? And what is the correct way to get
file name for all browsers then?

P.S.
Sorry, if my question is silly.


redo

Reply via email to