You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by redomancer redomancer <re...@gmail.com> on 2007/07/18 18:29:36 UTC
IE7 and Apache Common File Upload
Hello!
I am not sure i am posting the questions in right place, but i have no other
option.
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
Re: IE7 and Apache Common File Upload
Posted by "Walter E. Zegarra Sánchez" <wa...@gmail.com>.
Yes, you do, use the filecommonupload old version... i'm usin that version,
i dont remember what number because i'm not stay in my office. If you can,
writeme to walterin@gmail.com to remember and send the code for the group
and for you.
atte.
Walter E. Zegarra
Synopsis Developer
walterin@gmail.com
Lima - Peru
2007/7/18, Martin Cooper <ma...@apache.org>:
>
> On 7/18/07, redomancer redomancer <re...@gmail.com> 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
> >
>
--
Don´t Worry Be Walter & Alexita....!!!
Re: IE7 and Apache Common File Upload
Posted by Martin Cooper <ma...@apache.org>.
On 7/18/07, redomancer redomancer <re...@gmail.com> 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
>